I’ve Written The Code For The Button’s Click Event, But Nothing Happens When I Click It At Run Time. Why?

try this:

Public Class Form1

Dim a as string
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    MsgBox("You Typed" + a + "!")
End Sub

Private Sub keyentered(e As KeyEventArgs)
    If e.KeyCode = Keys.E Then
        a = "e"
MsgBox("You Typed" + a + "!")
    End If
End Sub

if it doesnt work, add a textbox, then type it but like this:

Public Class Form1

Dim a as string
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    MsgBox("You Typed" + a + "!")
End Sub

Private Sub keyentered(e As KeyEventArgs)
    If e.KeyCode = Keys.E Then
        a = "e"
MsgBox("You Typed" + a + "!")
    End If
End Sub

private sub textbox1_textchanged(e As KeyEventArgs) Handeles Textbox1.textchanged

 If e.KeyCode = Keys.a Then
            a = "a"
    textbox1.text = ""
    MsgBox("You Typed" + a + "!")
        End If
    End Sub

end sub

Edit1:
keep on doing this until you get to Z

Edit2:
Make sure you have keyeventargs and not eventargs, else you’ll get an error.

Leave a Comment