- This topic shows how to check whether caps lock on or off and also check whether num lock on or off using vb.net
- This topic explained in an easy way to check whether caps lock and num lock on or off
VB.NET – To check whether caps lock or num lock on or off in vb.net
- VB.NET means Visual Basic.NET.
- It’s an OOP’s language.
- VB.NET is a .NET version of Visual Basic programming language.
- VB.NET uses CLR for program execution.
- According to Microsoft VB.NET was re-engineered rather than released as Visual Basic 6.0 with some add-ons.
- Different versions of VB.NET are available.
- Know more about VB.NET
Control Class – To check whether caps lock or num lock on or off in vb.net
- Control class defines the base class for controls, which are components with visual representation.
Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
- Syntax
|
1 2 3 4 5 6 7 |
'Declaration <ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)> _ <ComVisibleAttribute(True)> _ Public Class Control _ Inherits Component _ Implements IDropTarget, ISynchronizeInvoke, IWin32Window, IBindableComponent, _ IComponent, IDisposable |
Control.IsKeyLocked Method – To check whether caps lock or num lock on or off in vb.net
- Control.IsKeyLocked Method determines whether the CAPS LOCK, NUM LOCK, or SCROLL LOCK key is in effect.
- Use the IsKeyLocked property to determine whether the CAPS LOCK, NUM LOCK, or SCROLL LOCK keys are on, whether individually or in combination.
Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
- Syntax
|
1 2 3 4 |
'Declaration Public Shared Function IsKeyLocked ( _ keyVal As Keys _ ) As Boolean |
Parameters
- keyVal
- Type: System.Windows.Forms.Keys
- The CAPS LOCK, NUM LOCK, or SCROLL LOCK member of the Keys enumeration.
Return Value
- Type: System.Boolean
- True if the specified key or keys are in effect; otherwise, false.
To check whether caps lock or num lock on or off in vb.net – Complete Code
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
Public Class Form3 Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'To check CapsLock If Control.IsKeyLocked(Keys.CapsLock) Then MsgBox("The Caps Lock key is ON.") Else MsgBox("The Caps Lock key is OFF.") End If 'To check Numlock If Control.IsKeyLocked(Keys.NumLock) Then MsgBox("The Num Lock key is ON.") Else MsgBox("The Num Lock key is OFF.") End If End Sub End Class |






