473,322 Members | 1,736 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

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

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
Dec 21 '05 #1
3 14113
> 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
Dec 21 '05 #2
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
Dec 21 '05 #3
"ngreplies" <ng*******@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/>
Dec 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: worzel | last post by:
Can't suss this out for the life of me, googling of no help either. Okay, new to win forms; I have a treeview with several root nodes, each having a single level of child nodes underneath. I also...
388
by: maniac | last post by:
Hey guys, I'm new here, just a simple question. I'm learning to Program in C, and I was recommended a book called, "Mastering C Pointers", just asking if any of you have read it, and if it's...
5
by: Christian Pické | last post by:
Hi, I want to deploy my Windows Application written in C#. I am using SQL Server and I wonder if there is a way to detect computers that run SQL Server or MSDE, so I can connect to them 1) to...
2
by: Matt Sawyer | last post by:
Hi, I'm attempting to do a drag and drop operation from one listbox to another. I have my listboxes setup with SelectionMode = MultiExtended so that I can use the shift key, cntrl key, etc. to...
3
by: Tegdeep | last post by:
Here's what I want to do: I have a hash table which contains data associated to different keys. The Hash keys are represented by a single character from the keyboard: 0-9, a-z, A-Z, and the...
2
by: Steph. | last post by:
Hi, A simple question : How can I detect if the CTRL key is pressed when User click on a control ? Thanks, Steph.
3
by: surya52 | last post by:
I want to disable right click in my application.Here are my requirements. 1. I don't what to turn off shift click for the page. I want to turn it off for specific links. 2. I want shift-click to...
1
by: jonathanmcdougall | last post by:
I am developing a calendar on which dates can be clicked and selected. A calendar is a table in which each day is a cell. Each cell has a unique id. By left-clicking on a date, it gets selected...
1
by: mark4asp | last post by:
<!-- // How to detect the rendering mode which the browser is currently in (works for IE6). // Ctrl+Shift+s displays indicates whether the browser is in quirks or standards mode. // Detect...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.