Richtextbox Change input

CoDeR

Member
Joined
Feb 6, 2006
Messages
6
Location
UK
Programming Experience
Beginner
how can i make it so when the user inputs a text sting of maybe abc then clicks convert it makes a=1 b=2 c=3 so it outputs 123
 
in the button's click event:
VB.NET:
Dim txt As String = RichTextBox1.Text
txt.Replace("a", "1")
txt.Replace("b", "2")
txt.Replace("c", "3")
RichTextBox1.Text = txt
 
ok i used the on click event code and it doesnt work and can someone explain the use of the second code???
 
I neglected to have it assign the replaced values to the variable, this works:
VB.NET:
Dim txt As String = RichTextBox1.Text
txt = txt.Replace("a", "1")
txt = txt.Replace("b", "2")
txt = txt.Replace("c", "3")
RichTextBox1.Text = txt
 
VB.NET:
Dim str1 As String = Me.TextBox1.Text
        Dim str2 As String
  Dim ch As Char
        For Each ch In str1
            str2 &= (Convert.ToInt32(Char.ToUpper(ch)) - 64).ToString()
        Next ch
        MsgBox(str2)
 
thanks for all the help, that part works great now but is there a way to select individual word without knowing what they are going to be. so when the button is clicked it will find the first word and put it into a variable:)
 
aniskhan said:
VB.NET:
Dim str1 As String = Me.TextBox1.Text
        Dim str2 As String
  Dim ch As Char
        For Each ch In str1
            str2 &= (Convert.ToInt32(Char.ToUpper(ch)) - 64).ToString()
        Next ch
        MsgBox(str2)
Nice code. ;)
 
CoDeR said:
thanks for all the help, that part works great now but is there a way to select individual word without knowing what they are going to be. so when the button is clicked it will find the first word and put it into a variable:)
The first word ends at the first space, so you can use String.Substring and String.IndexOf together to get the substring up to the index of the first space.
 
thanks for all the great help this is a great community a special thanks to jmcilhinney for all the help with my thread and to JuggaloBrotha for the great code and simplisety the moderators here do a fantastic job :)
one last thing can anyone help with the first word problem i didnt understand the help jmcilhinney gave soz
 
Last edited:
Back
Top