Question: I am new to Visual Basic and wanted to create an access key for my Windows Form application. How can I do that?

Answer: By definition an access key is an underlined character in the text of a menu or the label of a control. The idea of an access key is that the user can activate the control or menu item by pressing a combination of the ALT key and pre-defined access key.

For a simple example if we created a simple Windows form application that contains a single button. Then enter the following code.

Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Button1.Text = "&Click"

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        MsgBox("You clicked me!")

    End Sub

End Class

Run the application

Using ALT-C activate the access key