A common feature of a status bar is a small panel telling you if the CAPS lock is on or off. The code below shows you how to determine this, so you can add a panel to your status bar too!
Option Explicit
Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey
As Long) As Integer
Public Function CapsLockOn() As Boolean
Dim iKeyState As Integer
iKeyState = GetKeyState(vbKeyCapital)
CapsLockOn = (iKeyState = 1 Or iKeyState = -127)
End Function
Private Sub cmdIsCapsOn_Click()
If CapsLockOn = True Then
MsgBox "Yes, Capslock is on!"
Else
MsgBox "No, Capslock is NOT
on!"
End If
End Sub
Comments