none
Code for replacing characters from string is not working. RRS feed

  • Question

  • Hi guys.

    i want to make program that reads Russian Character string and the replace all the letters from Russian to Latin(English) character.

    So i created two tables and gave values to the table's fields. then i write simple code, using "For i = number to number" and "Next i". for some reason, it don't give me back what i want. It keeps copying the Russian letter and pasting it to the second text box. If any one can help, please take a look:

    Dim russianletters(0 To 32) As String
            Dim greekletters(0 To 32) As String
            Dim i As Integer

            russianletters(0) = "А"
            russianletters(1) = "Б"
            russianletters(2) = "В"
            russianletters(3) = "Г"
            russianletters(4) = "Д"
            russianletters(5) = "Е"
            russianletters(6) = "Ё"
            russianletters(7) = "Ж"
            russianletters(8) = "З"
            russianletters(9) = "И"
            russianletters(10) = "Й"
            russianletters(11) = "К"
            russianletters(12) = "Л"
            russianletters(13) = "М"
            russianletters(14) = "Н"
            russianletters(15) = "О"
            russianletters(16) = "П"
            russianletters(17) = "Р"
            russianletters(18) = "С"
            russianletters(19) = "Т"
            russianletters(20) = "У"
            russianletters(21) = "Ф"
            russianletters(22) = "Х"
            russianletters(23) = "Ц"
            russianletters(24) = "Ч"
            russianletters(25) = "Ш"
            russianletters(26) = "Щ"
            russianletters(27) = "Ъ"
            russianletters(28) = "Ы"
            russianletters(29) = "Ь"
            russianletters(30) = "Э"
            russianletters(31) = "Ю"
            russianletters(32) = "Я"

            latinletters(0) = "A"
            latinletters(1) = "b"
            latinletters(2) = "v"
            latinletters(3) = "g"
            latinletters(4) = "d"
            latinletters(5) = "ye"
            latinletters(6) = "yo"
            latinletters(7) = "s"
            latinletters(8) = "z"
            latinletters(9) = "e"
            latinletters(10) = "y"
            latinletters(11) = "k"
            latinletters(12) = "l"
            latinletters(13) = "m"
            latinletters(14) = "n"
            latinletters(15) = "o"
            latinletters(16) = "p"
            latinletters(17) = "r"
            latinletters(18) = "s"
            latinletters(19) = "t"
            latinletters(20) = "oo"
            latinletters(21) = "f"
            latinletters(22) = "gh"
            latinletters(23) = "ts"
            latinletters(24) = "ch"
            latinletters(25) = "sh"
            latinletters(26) = "sh"
            latinletters(27) = ""
            latinletters(28) = "e"
            latinletters(29) = ""
            latinletters(30) = "e"
            latinletters(31) = "u"
            latinletters(32) = "ya"

            Dim bigletters As String = oldname.Text
            For i = 0 To 32
                Dim abigletters As String = Replace(bigletters, russianletters(i), greekletters(i))
                newname.Text = abigletters
            Next i

    For some reason i get it done with the small letters and when i wanted to use same way on big letters, i get fail results. I think the code is ok, i just don't know if there is a problem with the dim functions or anything else.

    THANKS FOR READING


    Thursday, May 3, 2012 8:36 PM

Answers

  • If I understand you correctly, I believe you want something like:

    Dim bigletters As String = oldname.Text
    
    For i = 0 To 32
        bigletters = bigletters.Replace(russianletters(i), greekletters(i))
    Next i
    
    newname.Text = bigletters
    


    Reed Copsey, Jr. - http://reedcopsey.com
    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".

    • Proposed as answer by Papy Normand Thursday, May 3, 2012 10:19 PM
    • Marked as answer by Andrikos Rikos Friday, May 4, 2012 3:17 PM
    Thursday, May 3, 2012 9:29 PM
    Moderator

All replies

  • I mistake, and put in this forum the "greekletters", but actually i wanted to write latinletters. in anyway it is not working.
    Thursday, May 3, 2012 8:38 PM
  • If I understand you correctly, I believe you want something like:

    Dim bigletters As String = oldname.Text
    
    For i = 0 To 32
        bigletters = bigletters.Replace(russianletters(i), greekletters(i))
    Next i
    
    newname.Text = bigletters
    


    Reed Copsey, Jr. - http://reedcopsey.com
    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".

    • Proposed as answer by Papy Normand Thursday, May 3, 2012 10:19 PM
    • Marked as answer by Andrikos Rikos Friday, May 4, 2012 3:17 PM
    Thursday, May 3, 2012 9:29 PM
    Moderator
  • Thank you very much. It worked perfectly. I am really appreciate your help!!!!!!!! 
    Friday, May 4, 2012 3:18 PM