Visual basic express help

Discussion in 'Programming' started by awsomnick1, Apr 17, 2010.

  1. #1
    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
     
    awsomnick1, Apr 17, 2010 IP
  2. ccoonen

    ccoonen Well-Known Member

    Messages:
    1,606
    Likes Received:
    71
    Best Answers:
    0
    Trophy Points:
    160
    #2
    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
     
    ccoonen, Apr 17, 2010 IP
  3. awsomnick1

    awsomnick1 Active Member

    Messages:
    109
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    53
    #3
    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
     
    awsomnick1, Apr 17, 2010 IP
  4. NeoCambell

    NeoCambell Peon

    Messages:
    456
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #4
    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)
     
    NeoCambell, Apr 18, 2010 IP