How to Find Which Key is Pressed In Vb.Net

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:

Download Now (.Zip File 115 KB)…

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

CommentLuv badge

Human Verification: In order to verify that you are a human and not a spam bot, please enter the answer into the following box below based on the instructions contained in the graphic.