0

Hi everyone. im kinda bored so i made my own code language. the code is like a=e b=q c=m d=p e=i ect. so i made it into a program. so i started to fill in the code:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim text As String
        text = TextBox1.Text.Replace("A", "E").Replace("a", "e")
        MsgBox(text & "!", MsgBoxStyle.OkOnly, "Replace String Example")
    End Sub

and i typed in "Aa" and i got a msgbox that said "Ee!"

so then i started to type in more:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim text As String
        text = TextBox1.Text.Replace("A", "E").Replace("a", "e").Replace("B", "Q").Replace("b", "q").Replace("C", "M").Replace("c", "m").Replace("D", "P").Replace("d", "p").Replace("E", "I").Replace("e", "i")
        MsgBox(text & "!", MsgBoxStyle.OkOnly, "Replace String Example")
    End Sub

i typed in "Trixie is a good cat" and got a msgbox that said "Trixii is i goop mit!" I know why it did this. for the word cat i was supposed 2 get "met" but got "mit". its because a changes to e but e changes to i. i want the code to replace the letter only once like a to e, and not to change twice like a to e e to i. can someone help me with that??? thx!

2
Contributors
4
Replies
6
Views
4 Years
Discussion Span
Last Post by Programmer629
Featured Replies
  • 1

    Read here: http://www.daniweb.com/software-development/vbnet/threads/375191/translating-text Read More

  • 1

    The only way for you to replace only the "encoded" characters is to go character by character. Your best bet is to use a dictionary and step through each character. There is no difference between what you are trying to do and the post I've mentioned above . The easiest … Read More

1

The only way for you to replace only the "encoded" characters is to go character by character. Your best bet is to use a dictionary and step through each character.
There is no difference between what you are trying to do and the post I've mentioned above .
The easiest way for you to do it is to use GeekByChoiCe's code and change the dictionary to fit your "language". If you don't want to do it in a second textbox, then use a variable for your conversion and at the end change your textbox.text to what the variable holds.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.