Public Class Form1 Friend Class NativeMethods Public Const VK_NUMLOCK As Integer = &H90 Friend Const KEYEVENTF_KEYUP As Integer = &H2 Private Sub New() End Sub <System.Runtime.InteropServices.DllImport("user32.dll")> _ Friend Shared Sub keybd_event(ByVal bVirtualKey As Byte, ByVal bScanCode As Byte, ByVal dwFlags As Integer, ByVal dwExtraInfo As Integer) End Sub End Class Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged If CheckBox1.CheckState = CheckState.Checked Then SetKeybdStatus(True) Else SetKeybdStatus(False) End If End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load If CheckBox1.Checked <> Control.IsKeyLocked(Keys.NumLock) Then CheckBox1.Checked = Control.IsKeyLocked(Keys.NumLock) End If End Sub Private Sub SetKeybdStatus(ByVal bOnOffFlag As Boolean) If Control.IsKeyLocked(Keys.NumLock) <> bOnOffFlag Then NativeMethods.keybd_event(NativeMethods.VK_NUMLOCK, &H45, 0, 0) NativeMethods.keybd_event(NativeMethods.VK_NUMLOCK, &H45, NativeMethods.KEYEVENTF_KEYUP, 0) End If End Sub End Class