I don't know if it is ethical to change the keyboard setting. I would be very annoyed as a user if the program later required lower case and I continually started typing in upper case as a result. The usual method is to accept any input and change it using Ucase() afterwards. However, for the sake of the exercise, this code will do the job (can check by seeing the light on the keyboard come on).
'---------------------------------------------------
Private Declare Function GetKeyState Lib "user32" _
(ByVal nVirtKey As Long) As Long
'-
Private Declare Sub keybd_event Lib "user32" _
(ByVal bVk As Byte, ByVal bScan As Byte, _
ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
'-
Private Declare Function MapVirtualKey Lib "user32" _
Alias "MapVirtualKeyA" _
(ByVal wCode As Long, ByVal wMapType As Long) As Long
'--------------------------------------------------------
Private Sub CAPS_LOCK_ON()
'- if caps lock off then 'press' key
If GetKeyState(&H14) = 0 Then
Call keybd_event(&H14, _
MapVirtualKey(&H14, 0), KEYEVENTF_EXTENDEDKEY Or 0, 0)
Call keybd_event(&H14, _
MapVirtualKey(&H14, 0), KEYEVENTF_EXTENDEDKEY Or KEYEVENTF_KEYUP, 0)
End If
End Sub
'------------------------------------------------------
Regards
BrianB
** Let us know if you get something that works !
================================