Solved

Small script to enable the Num Lock key

Posted on 1998-02-12
2
369 Views
Last Modified: 2012-05-07
How to use a small QB/VB script to enable the Num Lock key?
(Preferer use QB command if you know.)

Thanks.
0
Comment
Question by:st
  • 2
2 Comments
 
LVL 7

Accepted Solution

by:
kamall earned 30 total points
Comment Utility
The KeyState custom control that is shipped with VB can do this job. It can turn ON and OFF the NumLock, CapsLock, ScrollLock, and the INS keys.
I had some code for QB but I couldn't find it at this moment. I will try to search for it.
Regards
0
 
LVL 7

Expert Comment

by:kamall
Comment Utility
Here is some other code for manipulating the CapsLock, NumLock, etc. without using the KeyState control (in VB):

Functin GetCapslock() As Boolean
'     ' Return or set the Capslock toggle.
GetCapslock = CBool(GetKeyState(vbKeyCapital) And 1)
End Function

Fuction GetNumlock() As Boolean
'     ' Return or set the Numlock toggle.
GetNumlock = CBool(GetKeyState(vbKeyNumlock) And 1)
End Function


Function GetScrollLock() As Boolean

       '     ' Return or set the ScrollLock toggle.
       GetScrollLock = CBool(GetKeyState(vbKeyScrollLock) And 1)
End Function


Sub SetCapslock(Value As Boolean)

       '     ' Return or set the Capslock toggle.
       Call SetKeyState(vbKeyCapital, Value)
End Sub


Sub SetNumlock(Value As Boolean)

       '     ' Return or set the Numlock toggle.
       Call SetKeyState(vbKeyNumlock, Value)
End Sub

Set SetScrollLock(Value As Boolean)
'     ' Return or set the ScrollLock toggle.
Call SetKeyState(vbKeyScrollLock, Value)
End Sub


Private Sub SetKeyState(intKey As Integer, fTurnOn As Boolean)

       '     ' Retrieve the keyboard state, set the particular
       '     ' key in which you're interested, and then set
       '     ' the entire keyboard state back the way it
       '     ' was, with the one key altered.
       Dim abytBuffer(0 To 255) As Byte
       GetKeyboardState abytBuffer(0)
       abytBuffer(intKey) = CByte(Abs(fTurnOn))
       SetKeyboardState abytBuffer(0)
End Sub


0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now