Prøv at indsætte denne kode i en form..
og prøv så at tryk på F tasterne
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyF1 Then Label1.Caption = "F1"
If KeyCode = vbKeyF2 Then Label1.Caption = "F2"
If KeyCode = vbKeyF3 Then Label1.Caption = "F3"
If KeyCode = vbKeyF4 Then Label1.Caption = "F4"
If KeyCode = vbKeyF5 Then Label1.Caption = "F5"
If KeyCode = vbKeyF6 Then Label1.Caption = "F6"
If KeyCode = vbKeyF7 Then Label1.Caption = "F7"
If KeyCode = vbKeyF8 Then Label1.Caption = "F8"
If KeyCode = vbKeyF9 Then Label1.Caption = "F9"
If KeyCode = vbKeyF10 Then Label1.Caption = "F10"
If KeyCode = vbKeyF11 Then Label1.Caption = "F11"
If KeyCode = vbKeyF12 Then Label1.Caption = "F12"
If KeyCode = vbKeyF13 Then Label1.Caption = "F13"
If KeyCode = vbKeyF14 Then Label1.Caption = "F14"
If KeyCode = vbKeyF15 Then Label1.Caption = "F15"
If KeyCode = vbKeyF16 Then Label1.Caption = "F16"
End Sub
Her er til hele tastaturet
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyQ Then Label1.Caption = "Q"
If KeyCode = vbKeyW Then Label1.Caption = "W"
If KeyCode = vbKeyE Then Label1.Caption = "E"
If KeyCode = vbKeyR Then Label1.Caption = "R"
If KeyCode = vbKeyT Then Label1.Caption = "T"
If KeyCode = vbKeyZ Then Label1.Caption = "Z"
If KeyCode = vbKeyU Then Label1.Caption = "U"
If KeyCode = vbKeyI Then Label1.Caption = "I"
If KeyCode = vbKeyO Then Label1.Caption = "O"
If KeyCode = vbKeyP Then Label1.Caption = "P"
If KeyCode = vbKeyA Then Label1.Caption = "A"
If KeyCode = vbKeyS Then Label1.Caption = "S"
If KeyCode = vbKeyD Then Label1.Caption = "D"
If KeyCode = vbKeyF Then Label1.Caption = "F"
If KeyCode = vbKeyG Then Label1.Caption = "G"
If KeyCode = vbKeyH Then Label1.Caption = "H"
If KeyCode = vbKeyJ Then Label1.Caption = "J"
If KeyCode = vbKeyK Then Label1.Caption = "K"
If KeyCode = vbKeyL Then Label1.Caption = "L"
If KeyCode = vbKeyY Then Label1.Caption = "Y"
If KeyCode = vbKeyX Then Label1.Caption = "X"
If KeyCode = vbKeyC Then Label1.Caption = "C"
If KeyCode = vbKeyV Then Label1.Caption = "V"
If KeyCode = vbKeyB Then Label1.Caption = "B"
If KeyCode = vbKeyN Then Label1.Caption = "N"
If KeyCode = vbKeyM Then Label1.Caption = "M"
If KeyCode = vbKeySpace Then Label1.Caption = "SPACE"
If KeyCode = vbKey1 Then Label1.Caption = "1"
If KeyCode = vbKey2 Then Label1.Caption = "2"
If KeyCode = vbKey3 Then Label1.Caption = "3"
If KeyCode = vbKey4 Then Label1.Caption = "4"
If KeyCode = vbKey5 Then Label1.Caption = "5"
If KeyCode = vbKey6 Then Label1.Caption = "6"
If KeyCode = vbKey7 Then Label1.Caption = "7"
If KeyCode = vbKey8 Then Label1.Caption = "8"
If KeyCode = vbKey9 Then Label1.Caption = "9"
If KeyCode = vbKey0 Then Label1.Caption = "0"
If KeyCode = vbKeyNumpad0 Then Label1.Caption = "0"
If KeyCode = vbKeyNumpad1 Then Label1.Caption = "1"
If KeyCode = vbKeyNumpad2 Then Label1.Caption = "2"
If KeyCode = vbKeyNumpad3 Then Label1.Caption = "3"
If KeyCode = vbKeyNumpad4 Then Label1.Caption = "4"
If KeyCode = vbKeyNumpad5 Then Label1.Caption = "5"
If KeyCode = vbKeyNumpad6 Then Label1.Caption = "6"
If KeyCode = vbKeyNumpad7 Then Label1.Caption = "7"
If KeyCode = vbKeyNumpad8 Then Label1.Caption = "8"
If KeyCode = vbKeyNumpad9 Then Label1.Caption = "9"
If KeyCode = vbKeyLeft Then Label1.Caption = "LEFT"
If KeyCode = vbKeyRight Then Label1.Caption = "RIGHT"
If KeyCode = vbKeyUp Then Label1.Caption = "UP"
If KeyCode = vbKeyDown Then Label1.Caption = "DOWN"
If KeyCode = vbKeyAdd Then Label1.Caption = "ADD"
If KeyCode = vbKeyBack Then Label1.Caption = "BACK"
If KeyCode = vbKeyCancel Then Label1.Caption = "CANCEL"
If KeyCode = vbKeyCapital Then Label1.Caption = "CAPITAL"
If KeyCode = vbKeyClear Then Label1.Caption = "CLEAR"
If KeyCode = vbKeyControl Then Label1.Caption = "CONTROL"
If KeyCode = vbKeyDecimal Then Label1.Caption = "DECIMAL"
If KeyCode = vbKeyDelete Then Label1.Caption = "DELETE"
If KeyCode = vbKeyDivide Then Label1.Caption = "DIVIDE"
If KeyCode = vbKeyEnd Then Label1.Caption = "END"
If KeyCode = vbKeyEscape Then Label1.Caption = "ESCAPE"
If KeyCode = vbKeyExecute Then Label1.Caption = "EXECUTE"
If KeyCode = vbKeyF1 Then Label1.Caption = "F1"
If KeyCode = vbKeyF2 Then Label1.Caption = "F2"
If KeyCode = vbKeyF3 Then Label1.Caption = "F3"
If KeyCode = vbKeyF4 Then Label1.Caption = "F4"
If KeyCode = vbKeyF5 Then Label1.Caption = "F5"
If KeyCode = vbKeyF6 Then Label1.Caption = "F6"
If KeyCode = vbKeyF7 Then Label1.Caption = "F7"
If KeyCode = vbKeyF8 Then Label1.Caption = "F8"
If KeyCode = vbKeyF9 Then Label1.Caption = "F9"
If KeyCode = vbKeyF10 Then Label1.Caption = "F10"
If KeyCode = vbKeyF11 Then Label1.Caption = "F11"
If KeyCode = vbKeyF12 Then Label1.Caption = "F12"
If KeyCode = vbKeyF13 Then Label1.Caption = "F13"
If KeyCode = vbKeyF14 Then Label1.Caption = "F14"
If KeyCode = vbKeyF15 Then Label1.Caption = "F15"
If KeyCode = vbKeyF16 Then Label1.Caption = "F16"
If KeyCode = vbKeyHelp Then Label1.Caption = "HELP"
If KeyCode = vbKeyHome Then Label1.Caption = "HOME"
If KeyCode = vbKeyInsert Then Label1.Caption = "INSERT"
If KeyCode = vbKeyLButton Then Label1.Caption = "LBUTTON"
If KeyCode = vbKeyMButton Then Label1.Caption = "MBUTTON"
If KeyCode = vbKeyMenu Then Label1.Caption = "MENU"
If KeyCode = vbKeyMultiply Then Label1.Caption = "MULTIPLY"
If KeyCode = vbKeyNumlock Then Label1.Caption = "NUMLOCK"
If KeyCode = vbKeyPageDown Then Label1.Caption = "PAGE DOWN"
If KeyCode = vbKeyPageUp Then Label1.Caption = "PAGE UP"
If KeyCode = vbKeyPause Then Label1.Caption = "PAUSE"
If KeyCode = vbKeyPrint Then Label1.Caption = "PRINT"
If KeyCode = vbKeyRButton Then Label1.Caption = "RBUTTON"
If KeyCode = vbKeyReturn Then Label1.Caption = "RETURN"
If KeyCode = vbKeyScrollLock Then Label1.Caption = "SCROLL LOCK"
If KeyCode = vbKeySelect Then Label1.Caption = "SELECT"
If KeyCode = vbKeySeparator Then Label1.Caption = "SEPARATOR"
If KeyCode = vbKeyShift Then Label1.Caption = "SHIFT"
If KeyCode = vbKeySnapshot Then Label1.Caption = "SNAPSHOT"
If KeyCode = vbKeySpace Then Label1.Caption = "SPACE"
If KeyCode = vbKeySubtract Then Label1.Caption = "SUBTRACT"
If KeyCode = vbKeyTab Then Label1.Caption = "TAB"
End Sub
Indlæg senest redigeret d. 24.01.2007 16:25 af Bruger #8719