fmShiftMask constants

Cas
05-29-2008, 08:04 AM
Just out of curiosity...

You can identify individual keyboard modifiers by using the following constants:

Constant Value Description
fmShiftMask 1 Mask to detect SHIFT.
fmCtrlMask 2 Mask to detect CTRL.
fmAltMask 4 Mask to detect ALT.

Those constants don't seem to be exist in "my" VBA (Excel 2002/10/XP) - no matches in the object browser, "variable not defined" when used in code. Could people verify that in other copies and versions?

Thanks. :)

Kluz
05-29-2008, 09:16 PM
Look just under Figure 1. (http://msdn.microsoft.com/en-us/library/aa155610(office.10).aspx) Looks like a KeyDown returned argument. Check out the VBA help file (I use Office '97) titled: "KeyDown, KeyUp Events" or the VB6 help file titled: "Detecting SHIFT, CTRL, and ALT States"

Cas
05-30-2008, 05:19 AM
So, does '97's VBA actually have the constants, then? :confused:

My help for the Key events specifies the parameter as
ByVal Shift As fmShiftState
but when I implement the handler using the dropdowns it gives me
ByVal Shift As Integer
and the object browser is just as unaware of the fmShiftState enum as it is of its member consts.

Ah, well ... :-\

Kluz
05-30-2008, 08:10 PM
Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
MsgBox CInt(KeyCode)
MsgBox CInt(Shift)
End SubIn Excel '97 I get 16 and 1 for Shift, 17 and 2 for Ctrl and 18 and 4 for Alt.
Thank you Micro$oft!

Cas
05-30-2008, 08:19 PM
Okay, but you don't have the defined constants either, yes?

Sorry to be persistent... :p

Kluz
05-31-2008, 01:30 PM
If you mean the Object Browser doesn't recognize fmShiftMask, fmCtrlMask or fmAltMask, no they're not in the list of recognized constants. I can't pull a value for them in the immediate window either.
Persistence is a virtue in the world of programming.

Cas
05-31-2008, 02:38 PM
Yes, that's what I wanted to know. Thanks! :)

Colin Legg
06-01-2008, 08:47 AM
Just FYI it's the same for me in Excel 2007. :)

Cas
06-02-2008, 01:10 PM
Thanks! :)

I pretty much expected that. The most reasonable explanation is that the constants were "lost" in some VBA version change and the help not updated, it seems to me.

The first Excel version supporting VBA was apparently 5.0 in '93, meaning the VBA version would have been based on VB3. I don't suppose anyone would like to install Windows 3.1 and Excel 5 just to check, eh? :p

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum