By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,790 Members | 1,201 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,790 IT Pros & Developers. It's quick & easy.

Caps Key

P: 7
hi friends,
this is senny, here i have to solve my pbm thrugh ur kind suggestion.In my project ,i have to restrict the user to use "CAPS KEY" like when we go to login if caps pressed the msbbox is come with msg "caps key pressed".

thanks in advance
senny
Mar 26 '07 #1
Share this Question
Share on Google+
8 Replies


100+
P: 149
hi friends,
this is senny, here i have to solve my pbm thrugh ur kind suggestion.In my project ,i have to restrict the user to use "CAPS KEY" like when we go to login if caps pressed the msbbox is come with msg "caps key pressed".

thanks in advance
senny
Hi ,

If the CAPS LOCK is on and one trys to enter data then we can trap the Ascii code of the keys pressed and then display an message that CAPS letters are not allowed.

thanks
ansuman
Mar 26 '07 #2

100+
P: 375
Hi ,

If the CAPS LOCK is on and one trys to enter data then we can trap the Ascii code of the keys pressed and then display an message that CAPS letters are not allowed.

thanks
ansuman
As put up by ansuman try trapping the ascii code of keys
A carries an ascii code of 65 it continues till Z which has the ascii code of 90
Put an condition in keypress event
If KeyAscii >= 65 And KeyAscii <= 90 Then
Text1.Locked = True
Msgbox "CAPS ON"
Else
Text1.Locked = False
End If
Mar 26 '07 #3

Expert 5K+
P: 8,434
hi friends,
this is senny, here i have to solve my pbm thrugh ur kind suggestion.In my project ,i have to restrict the user to use "CAPS KEY" like when we go to login if caps pressed the msbbox is come with msg "caps key pressed".
Have a look at this link... How To Toggle the NUM LOCK, CAPS LOCK, and SCROLL LOCK Keys. Specifically, I think you'll be interested in the GetKeyboardState function.
Mar 27 '07 #4

P: 20
As put up by ansuman try trapping the ascii code of keys
A carries an ascii code of 65 it continues till Z which has the ascii code of 90
Put an condition in keypress event
If KeyAscii >= 65 And KeyAscii <= 90 Then
Text1.Locked = True
Msgbox "CAPS ON"
Else
Text1.Locked = False
End If

THIS DOESN'T WORK IF USER IS TYPING BYPRESSING SHIFT KEY
Mar 27 '07 #5

100+
P: 375
THIS DOESN'T WORK IF USER IS TYPING BYPRESSING SHIFT KEY
This WORKS even if user is typing by pressing shift key
Here the key Caps or Shift(in my code) is immaterial. All the code does is traps the ascii value in the IFfunction . So irrespective of of SHIFT or CAPS it will work.
I have verified it.
Mar 27 '07 #6

SammyB
Expert 100+
P: 807
hi friends,
this is senny, here i have to solve my pbm thrugh ur kind suggestion.In my project ,i have to restrict the user to use "CAPS KEY" like when we go to login if caps pressed the msbbox is come with msg "caps key pressed".

thanks in advance
senny
Senny, Killer is absolutely correct: For VBA and VB6, you need to use the GetKeyboardState api. (thanks, Killer, for the link! I added it to Favorites)

However, it is much easier in VB.NET, you just use the Control class:
Expand|Select|Wrap|Line Numbers
  1. If Control.IsKeyLocked(Keys.CapsLock) Then _
  2.     MsgBox("CAPS LOCK is ON!", MsgBoxStyle.Exclamation)
See, VB.DotNet really is nicer! ;) --Sam
Mar 27 '07 #7

Expert 5K+
P: 8,434
This WORKS even if user is typing by pressing shift key
Here the key Caps or Shift(in my code) is immaterial. All the code does is traps the ascii value in the IFfunction . So irrespective of of SHIFT or CAPS it will work.
I have verified it.
I think the basic problem here is that it won't tell you if the capslock key is down. All it will tell you is that an uppercase key was typed - however that happened.

The original poster was not looking for how to tell if an uppercase letter is typed. They wanted to be able to warn that the capslock is down - you know, the way Windows XP does at password entry.
Mar 27 '07 #8

100+
P: 375
I think the basic problem here is that it won't tell you if the capslock key is down. All it will tell you is that an uppercase key was type - however that happened.

The original poster was not looking for how to tell if an uppercase letter is typed. They wanted to be able to warn that the capslock is down - you know, the way Windows XP does at password entry.
I understood now. Went through your link. Wonderful article
Thanks killer
Mar 28 '07 #9

Post your reply

Sign in to post your reply or Sign up for a free account.