'**********first method*************** 'api const Private Const VK_NUMLOCK = &H90 'const to set numlock key Private Type KeyboardBytes kbByte(0 To 255) As Byte End Type Private kbArray As KeyboardBytes 'api declaration Private Declare Function GetKeyboardState Lib "user32" _ (kbArray As KeyboardBytes) As Long Private Declare Function SetKeyboardState Lib "user32" _ (kbArray As KeyboardBytes) As Long 'user proc Public Sub toggleNumLock() GetKeyboardState kbArray 'getting keyboard state kbArray.kbByte(VK_NUMLOCK) = IIf(kbArray.kbByte(VK_NUMLOCK) = 1, 0, 1) 'toggle between on and off of numlock SetKeyboardState kbArray End Sub Private Sub Command1_Click() Call toggleNumLock 'invoke toggle numlock End Sub '''**********alternative method dont use********* '''Private Const KEYEVENTF_KEYUP = &H2 '''Private Const NUMLOCK_ON = &H20 '''Private Const CAPSLOCK_ON = &H80 '''Private Const SCROLLLOCK_ON = &H40 '''Private Declare Function MapVirtualKey Lib "user32" Alias "MapVirtualKeyA" (ByVal wCode As Long, ByVal wMapType As Long) As Long '''Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan _ '''As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long) '''Private Sub Command1_Click() ''' Const MENU_KEYCODE = 144 '20-capslock,145-scrolllock,144-numlock ''' keybd_event MENU_KEYCODE, 0, 0, 0 ''' keybd_event MENU_KEYCODE, 0, KEYEVENTF_KEYUP, 0 '''End Sub '******************************************************** Private Declare Sub keybd_event Lib "user32" _ (ByVal bVk As Byte, _ ByVal bScan As Byte, _ ByVal dwFlags As Long, _ ByVal dwExtraInfo As Long) Private Const VK_LWIN = &H5B Private Const KEYEVENTF_KEYUP = &H2 Private Const VK_APPS = &H5D Private Sub Command1_Click(Index As Integer) Dim VK_ACTION As Long Select Case Index Case 0: '&H45 is the hex character code 'for the letter 'E' (ascii 69) 'Explorer VK_ACTION = &H45 Case 1: '&H46 is the hex character code 'for the letter 'F' (ascii 70) VK_ACTION = &H46 'Find Case 2: '&H4D is the hex character code 'for the letter 'M' (ascii 77) VK_ACTION = &H4D 'Minimize Case 3: '&H52 is the hex character code 'for the letter 'R' (ascii 82) VK_ACTION = &H52 'Run Command Case 4: '&H5B is the hex character code 'for the start menu button VK_ACTION = &H5B 'Start Button Case 5: '&H5E is the hex character code 'for the caret chr (ascii 94) VK_ACTION = &H5E 'Stand By Case 6: '&H70 is the hex character code 'for the caret chr (ascii 112) VK_ACTION = &H70 'Help End Select Call keybd_event(VK_LWIN, 0, 0, 0) Call keybd_event(VK_ACTION, 0, 0, 0) Call keybd_event(VK_LWIN, 0, KEYEVENTF_KEYUP, 0) End Sub