Keycode for uppercase letters

  • Thread starter Thread starter tim johnson
  • Start date Start date
T

tim johnson

I would like to identify with the KeyDown event when a
user enters lowercase i and o and upper case I and O.

I have been able to get the lowercase keycode as 73 and
79. I am having a problem for uppercase because I have to
hold the Shift key down and this complicates it.

How can I get the keycode for uppercase I and O using the
KeyDown procedure?

Thanks
 
You need to check the value of the Shift parameter. To do this you do a
bitwise AND with the appropriate mask to determine which of the Ctl, Alt &
Shift keys are down.

Dim fShift As Boolean 'True when Shift key is down
Dim fAlt As Boolean 'True when Alt key is down
Dim fCtl As Boolean 'True when Ctl key is down
fShift = Shift And acShiftMask
fAlt = Shift And acAltMask
fCtl = Shift And acCtrlMask

With this you can do your comparison:

if keycode=vbkeyI and fShift then
msgbox "It is uppercase I"
endif
 
Back
Top