I need help with my visual basic program Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged If TextBox1.Text = "h" Then TextBox2.AppendText("Hello" & Environment.NewLine) If TextBox1.Text = "b" Then TextBox2.AppendText("Bye& Environment.NewLine) I want it to type hello when i type h and bye when i type b and then hello and bye on seperate lines when i type hb
You need to wire into the on on text changed event for individual character management Private Sub TextBox1_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyUp If e.KeyData.ToString.ToLower.Equals("h") Then TextBox1.AppendText("ello" & Environment.NewLine) If e.KeyData.ToString.ToLower.Equals("b") Then TextBox1.AppendText("ye" & Environment.NewLine) End Sub
ok it works but what if i wanted to change the h or the b to a ! or a ? or :? I tried and it didnt work
What ccoonen has written is for h and b as asked by you in the first post. If you want such quick words for other letters, you will need to add same type of statement to each letter. For example if you want "contact" if "c" is pressed, then add, If e.KeyData.ToString.ToLower.Equals("c") Then TextBox1.AppendText("ontact" & Environment.NewLine)