外接键盘都有数字键盘,方便我们快速录入数字。有的时候我们会发现我们的数字键盘用不了。
原因就是禁止了。access禁止数字键盘是通过api函数。
下面是具体的代码。轻松关掉数字键!!
Dim bytKeys(255) As Byte
Dim bnumLockOn As Boolean
'Get status of the 256 virtual keys
GetKeyboardState bytKeys(0)
bnumLockOn = bytKeys(VK_NUMLOCK)
Dim typOS As OSVERSIONINFO
If bnumLockOn <> TurnOn Then 'if current state <>
'requested stae
If typOS.dwPlatformId = _
VER_PLATFORM_WIN32_WINDOWS Then '=== Win95/98
bytKeys(VK_NUMLOCK) = 1
SetKeyboardState bytKeys(0)
Else '=== WinNT/2000
'Simulate Key Press
keybd_event VK_NUMLOCK, &H45, _
KEYEVENTF_EXTENDEDKEY Or 0, 0
'Simulate Key Release
keybd_event VK_NUMLOCK, &H45, KEYEVENTF_EXTENDEDKEY _
Or KEYEVENTF_KEYUP, 0
End If
End If