Make your own free website on Tripod.com

Check If Caps Lock/Num Lock Is On

'Add a module to your project (In the menu choose Project -> Add Module, Then click Open)
'Insert this code to the module :

Public Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer

'Insert the following code to your form:

Private Sub Form_Load()
'This example will check if Caps Lock is on. to check if Num Lock is on,
'Replace the 'vbKeyCapital' below with 'vbKeyNumlock'
Tmp = GetKeyState(vbKeyCapital)
If Tmp = 1 Then
MsgBox "The Caps Lock Is On"
Else
MsgBox "The Caps Lock Is Off"
End If
End Sub

Go Back