Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / VB.NET / December 2005

Tip: Looking for answers? Try searching our database.

How can I detect if SHIFT key is selected when during Mousedown?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
ngreplies - 21 Dec 2005 08:53 GMT
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
Rick Rothstein [MVP - Visual Basic] - 21 Dec 2005 09:38 GMT
> 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
Oenone - 21 Dec 2005 11:35 GMT
> 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
///

Signature

(O)enone

Herfried K. Wagner [MVP] - 21 Dec 2005 11:38 GMT
"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
///

Signature

M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.