Q.: Create a Windows Application in VB.Net which is used to Find Which Key is pressed.
In VB.Net 2008, sometimes we have require to Find Which Key is pressed. This Example Shows to Find Which Key is pressed.
Compatibility/Version: Microsoft Visual Studio 2008 (Microsoft .Net Framework 3.5)
Source Code:
Public Class Form1
Dim a(4) As Char
Private Sub Control_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
Static Dim i As Integer
a(i) = e.KeyChar
i = i + 1
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
MsgBox("Your password is: " + a(0) + a(1) + a(2) + a(3) + a(4))
End
End Sub
End Class
Output:


