Hello,
I would like to have all data entered into every form in my database in all capital letters as a default. Is there a way to go about this?
martin DH
17 11548 Rabbit 12,516
Recognized Expert Moderator MVP
Sorry, don't know of a way to do this. I'm wondering if maybe you could retreive the status of the Caps Lock and send it if it's not on. But again, I don't know how to do this. Maybe someone else will be able to help. But I suppose you could have a checkbox that turns on and off whether or not the control capitalizes the string in the After Update event.
NeoPa 32,578
Recognized Expert Moderator MVP KeyPress Event
The KeyPress event occurs when the user presses and releases a key or key combination that corresponds to an ANSI code while a form or control has the focus. This event also occurs if you send an ANSI keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic. Private Sub object_KeyPress (KeyAscii As Integer)
Object "Form" or the name of a control on a Form. KeyAscii Returns a numeric ANSI key code. The KeyAscii argument is passed by reference; changing it sends a different character to the object. Setting the KeyAscii argument to 0 cancels the keystroke so that the object doesn't recognize that a key was pressed.
You can set this up for every form in your database. It's a little laborious maybe, but I'm not aware of any other way of doing it.
ADezii 8,834
Recognized Expert Expert
Hello,
I would like to have all data entered into every form in my database in all capital letters as a default. Is there a way to go about this?
martin DH
Don't think it can be done, but what you can do is force all lower case letters to be automatically entered as UPPERCASE in your Text Boxes as you type by copying this code into the KeyPress() Event of every Text Box on every Form. Other Control Types may have to be handled differently. As NeoPa stated, it would be just a little laborious but not ridiculous. - Private Sub txtCourse_KeyPress(KeyAscii As Integer)
-
If KeyAscii >= 97 And KeyAscii <= 122 Then 'lowercase a to z
-
KeyAscii = (KeyAscii - 32)
-
End If
-
End Sub
NeoPa 32,578
Recognized Expert Moderator MVP
500 posts ADezii - Nice going :)
As to your suggestion, would it not be a better idea to handle it at the form level? StartEdit:
As ADezii has pointed out later in this thread, you would need to set the KeyPreview property of the form to Yes for this to work correctly.
EndEdit:
At worst then, you may need a Select Case statement to avoid some controls but I can't think of any situations where even that would be required. - Private Sub Form_KeyPress(KeyAscii As Integer)
-
Select Case Chr(KeyAscii)
-
Case "a" To "z"
-
KeyAscii = KeyAscii - (Asc("a") - Asc("A"))
-
End Select
-
End Sub
This will involve fewer procedures, and be less laborious overall.
ADezii 8,834
Recognized Expert Expert
500 posts ADezii - Nice going :)
As to your suggestion, would it not be a better idea to handle it at the form level?
At worst then, you may need a Select Case statement to avoid some controls but I can't think of any situations where even that would be required. - Private Sub Form_KeyPress(KeyAscii As Integer)
-
Select Case Chr(KeyAscii)
-
Case "a" To "z"
-
KeyAscii = KeyAscii - (Asc("a") - Asc("A"))
-
End Select
-
End Sub
This will involve fewer procedures, and be less laborious overall.
NeoPa:
Thanks for the 500 Post compliment. You're right, it would work much better at the Form Level, but don't forget that you would have to set the Form's KeyView Property to Yes. - Why not eliminate 2 Function Calls?
-
KeyAscii = KeyAscii - (Asc("a") - Asc("A"))
-
KeyAscii = KeyAscii - 32
NeoPa 32,578
Recognized Expert Moderator MVP
NeoPa:
Thanks for the 500 Post compliment. You're right, it would work much better at the Form Level, but don't forget that you would have to set the Form's KeyView Property to Yes.
I forgot that a long time ago. I seem to recall that I did once need to use this and I suppose I must have known about or discovered the KeyPreview property then. - Why not eliminate 2 Function Calls?
-
KeyAscii = KeyAscii - (Asc("a") - Asc("A"))
-
KeyAscii = KeyAscii - 32
Because the benefit of the code showing clearly what it's doing outweighs the (in this case negligible) processing overhead. I considered the context, which is operator related, and I couldn't see any benefit in code efficiency here (It only gets run once per keystroke - I don't think even my wife could keep it busy enough :D).
NeoPa 32,578
Recognized Expert Moderator MVP
BTW You and I could both look at 32 in this context and immediately understand what it's referring to. Not everyone would find it that straightforward .
I did look at defining a constant for the value but it refused to evaluate a function in a constant declaration (as I suspected it would) so I had to revert to using the functions in the code.
BTW You and I could both look at 32 in this context and immediately understand what it's referring to. Not everyone would find it that straightforward .
I did look at defining a constant for the value but it refused to evaluate a function in a constant declaration (as I suspected it would) so I had to revert to using the functions in the code.
Thanks for your help! Martin DH
I also have my DBs set up to accept caps only. Here's the easy way to do it!
In a new module place this code: - 'Windows API/Global Declarations for :CapLock
-
'*********************************************
-
Public Const VK_CAPLOCK = &H14
-
-
Public Type KeyboardBytes
-
kbByte(0 To 255) As Byte
-
End Type
-
Public kbArray As KeyboardBytes
-
-
Public Declare Function GetKeyState Lib "user32" _
-
(ByVal nVirtKey As Long) As Long
-
Public Declare Function GetKeyboardState Lib "user32" _
-
(kbArray As KeyboardBytes) As Long
-
Public Declare Function SetKeyboardState Lib "user32" _
-
(kbArray As KeyboardBytes) As Long
When prompted name the module ControlCapsLock
In the On_Load sub of the first form in your db that is used place this code: - 'Turn Capslock On
-
GetKeyboardState kbArray
-
kbArray.kbByte(VK_CAPLOCK) = 1
-
SetKeyboardState kbArray
Then, in the last form you use before before unloading the application: - Private Sub Form_Unload(Cancel As Integer)
-
-
'Turn Capslock OFF
-
GetKeyboardState kbArray
-
kbArray.kbByte(VK_CAPLOCK) = 0
-
SetKeyboardState kbArray
-
End Sub
If you should have a field, like a memo field, where you don't want all caps, simply use the CapsLock Off code in the GotFocus event for the field, then the CapsLock On code in the LostFocus event for the field to reset it.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Robert |
last post by:
Hi!
I was wondering if the was any way to determine the state of the caps
lock key, on or off.
Of course I can capture the key events and see whether the caps lock is
pressed, but that does not help.
I have seen some example that looks at the characters entered in an
input field to determine if the caps lock is on, but I was wondering if
something is possible that is a bit more immediate to report the caps
|
by: Peter D |
last post by:
I have a second hand bar code reader (keyboard wedge) en i can read
the bar codes but after every scan he turns my caps lock on.
(GRRRRRR).
I search a code to turn my caps lock off or can anyone tell me why
(the hell)it happens that way.
|
by: Mike L |
last post by:
How do I turn Caps Lock on, when my form opens?
|
by: GSX |
last post by:
Would somebody be able to point me in the direction of figuring out how
to determine if Caps Lock is on, Num Lock is on, INS or OVR, etc.?
I'm looking to display their status in a statusbar, but I cannot seem to
find any info on how to retrieve their state.
Thank you very much in advance.
|
by: fNew VBer |
last post by:
Hi. I'm new to Visual Basic .NET, so you'll have to bear with me . . . I
want to create an app that turns off CAPS LOCK when the SHIFT key is pressed.
I got the code to turn off CAPS LOCK to work, but it only works when the
program has the focus. How can I write an app that will do this while
running in the background?
| |
by: yxq |
last post by:
Hello,
I have a main form, there other some controls(i.e. textbox) in the form.
I want to detect whether Caps Lock key is pressed in form-key event.
Private Sub Form1_KeyUp(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyUp
If e.KeyCode = 20 Then
MessageBox.Show("Caps Lock is pressed!")
End If
End Sub
|
by: charlies224 |
last post by:
Hi,
I am writting a software that requires me to make sure the Num Lock is
always on and Caps Lock is always off.
First, I know how to detect if Num Lock or Caps Lock is on or off (if
someone is interested, let me know and I will send you the codes). Once
we know if the stat of Num Lock/ Caps Lock is not what we desired, we
just send the Num Lock / Caps Lock key to change the stat. From most of
|
by: Brian Parker |
last post by:
I play a DirectX game and while that game is running, I would like to
change the behavior of the Caps Lock key. When it's pressed, I don't
want it to toggle my Caps Lock on and off, but instead send a different
code instead - preferably mimicing the 4th or 5th button of a mouse
being pressed.
1) Is this doable? If so...
2) What the general idea of how to approach this?
TIA,
|
by: zacks |
last post by:
I'm not sure when it came into being, since this it the first time I
have worked very much with a password control in .NET, but if a
textbox that has a non-empty value for PasswordChar or the
UseSystemPasswordChar property is true, and the textbox has focus, if
the Caps Lock key is pressed, a warning balloon tooltip is
automatically displayed by the system. I cannot even find
documentation that describes this behaviour.
My question is,...
|
by: cmrhema |
last post by:
Hi,
Two questions
1. In windows application if we put on the below code, it will identify whether caps lock is on or not
if (TextBox.IsKeyLocked(Keys.CapsLock))
{
MessageBox.Show("caps lock on");
}
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |