-6

I'm using VS2017 and vb.net to create a simple app that takes input as text from the user and when a button is clicked, it will display it in a MsgBox.

However, when i write the code in the buton's click event, nothing happens.

Please Help. Thanks in advance :)

Here's The Code-

Public Class Form1

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

End Class

Tejas
  • 1
  • 3

1 Answers1

0

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.