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!

Recommended Answers

All 4 Replies

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.

oh sry, i was lookin at the wrong post. thx for help!!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.