PC Review
Forums
Newsgroups
Microsoft DotNet
Microsoft VB .NET
How can I detect if SHIFT key is selected when during Mousedown?
Forums
Newsgroups
Microsoft DotNet
Microsoft VB .NET
How can I detect if SHIFT key is selected when during Mousedown?
![]() |
How can I detect if SHIFT key is selected when during Mousedown? |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
I have a need for an extra facility to be available when the user presses
the SHIFT key whilst clicking on either a Button Control or a textbox. I am using both VB6 and VB.NET2002. Could anyone please advise on the best way of managing this. Thanks in advance Terry |
|
|
|
#2 |
|
Guest
Posts: n/a
|
> I have a need for an extra facility to be available when the user presses
> the SHIFT key whilst clicking on either a Button Control or a textbox. > I am using both VB6 and VB.NET2002. > Could anyone please advise on the best way of managing this. Answer for VB6 ================ The TextBox and CommandButton controls both have MouseDown and MouseUp events... use one (or both depending on what you need) of them instead of the Click event... both the MouseDown and MouseUp events have a Shift parameter which you can test for... use the vbShiftMask constant to test the Shift parameter to see if the Shift key is down (you can also test for the Ctrl and Alt keys using this parameter). Answer for VB.NET2002 ====================== Almost everybody in this newsgroup is using VB6 or lower. While you may get a stray answer to VB.NET (including VB2003 and VB2005 which has dropped .NET from its name) questions here, you should ask them in newsgroups devoted exclusively to .NET programming (the languages are different enough to warrant separate newsgroup support). Look for newsgroups with either the word "dotnet" or "vsnet" in their name. For the microsoft news server, try these newsgroups for Visual Basic .NET related questions... microsoft.public.dotnet.languages.vb microsoft.public.dotnet.languages.vb.upgrade microsoft.public.dotnet.languages.vb.controls microsoft.public.dotnet.languages.vb.data And these for more general .NET questions microsoft.public.dotnet.general microsoft.public.vsnet.general Note: There are many other .NET newgroups (use the first three "fields" from the last two as templates when searching for them), but the above ones should get you started. Rick |
|
|
|
#3 |
|
Guest
Posts: n/a
|
Rick Rothstein [MVP - Visual Basic] wrote:
> Answer for VB.NET2002 > ====================== > Almost everybody in this newsgroup is using VB6 or lower. This was cross-posted to microsoft.public.dotnet.languages.vb, so the .NET people will already have seen it. The answer is to use the Control.ModifierKeys property, which will return a bit mask for each of the shift keys. To determine whether the Shift key is depressed: \\\ If (Control.ModifierKeys And Keys.Shift) <> 0 Then MsgBox("Shift is pressed.") End If /// -- (O)enone |
|
|
|
#4 |
|
Guest
Posts: n/a
|
"ngreplies" <ngreplies@voidtdrd.freeserve.co.uk> schrieb:
>I have a need for an extra facility to be available when the user presses > the SHIFT key whilst clicking on either a Button Control or a textbox. \\\ If CBool(Control.ModifierKeys And Keys.Shift) Then ... End If /// -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/> |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

