VERSION 5.00
Object = "{FE0065C0-1B7B-11CF-9D53-00AA003C9CB6}#1.1#0"; "COMCT232.OCX"
Begin VB.Form Form1 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "VB KeyAscii & KeyCode Finder"
   ClientHeight    =   6075
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   4260
   Icon            =   "Form1.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   ScaleHeight     =   6075
   ScaleWidth      =   4260
   StartUpPosition =   2  'CenterScreen
   Begin ComCtl2.UpDown UpDown4 
      Height          =   285
      Left            =   3495
      TabIndex        =   29
      Top             =   4665
      Width           =   255
      _ExtentX        =   450
      _ExtentY        =   503
      _Version        =   327681
      Max             =   255
      Enabled         =   -1  'True
   End
   Begin ComCtl2.UpDown UpDown3 
      Height          =   285
      Left            =   3495
      TabIndex        =   28
      Top             =   4335
      Width           =   255
      _ExtentX        =   450
      _ExtentY        =   503
      _Version        =   327681
      Max             =   255
      Enabled         =   -1  'True
   End
   Begin ComCtl2.UpDown UpDown2 
      Height          =   285
      Left            =   3495
      TabIndex        =   27
      Top             =   3215
      Width           =   255
      _ExtentX        =   450
      _ExtentY        =   503
      _Version        =   327681
      Max             =   255
      Enabled         =   -1  'True
   End
   Begin ComCtl2.UpDown UpDown1 
      Height          =   285
      Left            =   3495
      TabIndex        =   26
      Top             =   2865
      Width           =   255
      _ExtentX        =   450
      _ExtentY        =   503
      _Version        =   327681
      Max             =   255
      Enabled         =   -1  'True
   End
   Begin VB.Timer Timer2 
      Enabled         =   0   'False
      Interval        =   100
      Left            =   480
      Top             =   5520
   End
   Begin VB.Timer Timer1 
      Enabled         =   0   'False
      Interval        =   400
      Left            =   3480
      Top             =   5520
   End
   Begin VB.TextBox Text1 
      BeginProperty Font 
         Name            =   "Lucida Console"
         Size            =   9.75
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   300
      Left            =   1523
      MaxLength       =   1
      TabIndex        =   25
      TabStop         =   0   'False
      Text            =   "a"
      Top             =   480
      Width           =   1215
   End
   Begin VB.Frame Frame3 
      Caption         =   "Character Info"
      Height          =   1620
      Left            =   323
      TabIndex        =   13
      Top             =   840
      Width           =   3615
      Begin VB.TextBox Text4 
         Height          =   300
         Left            =   1800
         Locked          =   -1  'True
         TabIndex        =   21
         TabStop         =   0   'False
         Top             =   1200
         Width           =   1630
      End
      Begin VB.ComboBox Combo1 
         Height          =   315
         Left            =   1800
         TabIndex        =   20
         TabStop         =   0   'False
         Top             =   855
         Width           =   1630
      End
      Begin VB.TextBox Text3 
         Height          =   300
         Left            =   1800
         Locked          =   -1  'True
         TabIndex        =   19
         TabStop         =   0   'False
         Text            =   "65"
         Top             =   540
         Width           =   735
      End
      Begin VB.TextBox Text2 
         Height          =   300
         Left            =   1800
         Locked          =   -1  'True
         TabIndex        =   18
         TabStop         =   0   'False
         Text            =   "97"
         Top             =   240
         Width           =   735
      End
      Begin VB.Label Label15 
         AutoSize        =   -1  'True
         Caption         =   "Typed in key was:"
         Height          =   195
         Left            =   360
         TabIndex        =   17
         Top             =   1245
         Width           =   1290
      End
      Begin VB.Label Label14 
         AutoSize        =   -1  'True
         Caption         =   "VB Constant value is:"
         Height          =   195
         Left            =   135
         TabIndex        =   16
         Top             =   900
         Width           =   1515
      End
      Begin VB.Label Label13 
         AutoSize        =   -1  'True
         Caption         =   "KeyCode value is :"
         Height          =   195
         Left            =   330
         TabIndex        =   15
         Top             =   585
         Width           =   1320
      End
      Begin VB.Label Label12 
         AutoSize        =   -1  'True
         Caption         =   "KeyAscii value is :"
         Height          =   195
         Left            =   375
         TabIndex        =   14
         Top             =   285
         Width           =   1275
      End
   End
   Begin VB.Frame Frame2 
      Caption         =   "Difference between 2 KeyCode Values"
      Height          =   1320
      Left            =   323
      TabIndex        =   3
      Top             =   4080
      Width           =   3615
      Begin VB.TextBox Text10 
         BackColor       =   &H00C0FFFF&
         Height          =   300
         Left            =   1800
         Locked          =   -1  'True
         TabIndex        =   24
         TabStop         =   0   'False
         Text            =   "65 to 90"
         Top             =   885
         Width           =   1335
      End
      Begin VB.TextBox Text9 
         Height          =   300
         Left            =   1800
         MaxLength       =   3
         TabIndex        =   23
         TabStop         =   0   'False
         Text            =   "Z"
         Top             =   570
         Width           =   1335
      End
      Begin VB.TextBox Text8 
         Height          =   300
         Left            =   1800
         MaxLength       =   3
         TabIndex        =   22
         TabStop         =   0   'False
         Text            =   "A"
         Top             =   270
         Width           =   1335
      End
      Begin VB.Label Label11 
         AutoSize        =   -1  'True
         Caption         =   "KeyCode Values:"
         Height          =   195
         Left            =   425
         TabIndex        =   12
         Top             =   915
         Width           =   1215
      End
      Begin VB.Label Label10 
         AutoSize        =   -1  'True
         Caption         =   "2nd character:"
         Height          =   195
         Left            =   615
         TabIndex        =   11
         Top             =   615
         Width           =   1035
      End
      Begin VB.Label Label9 
         AutoSize        =   -1  'True
         Caption         =   "1st character:"
         Height          =   195
         Left            =   675
         TabIndex        =   10
         Top             =   315
         Width           =   975
      End
   End
   Begin VB.Frame Frame1 
      Caption         =   "Difference between 2 KeyAscii Values"
      Height          =   1320
      Left            =   323
      TabIndex        =   2
      Top             =   2610
      Width           =   3615
      Begin VB.TextBox Text7 
         BackColor       =   &H00C0FFFF&
         Height          =   300
         Left            =   1800
         Locked          =   -1  'True
         TabIndex        =   8
         TabStop         =   0   'False
         Text            =   "48 to 57"
         Top             =   900
         Width           =   1335
      End
      Begin VB.TextBox Text6 
         BeginProperty Font 
            Name            =   "Lucida Console"
            Size            =   9.75
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   300
         Left            =   1800
         MaxLength       =   3
         TabIndex        =   7
         TabStop         =   0   'False
         Text            =   "9"
         Top             =   580
         Width           =   1335
      End
      Begin VB.TextBox Text5 
         BeginProperty Font 
            Name            =   "Lucida Console"
            Size            =   9.75
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   300
         Left            =   1800
         MaxLength       =   3
         TabIndex        =   4
         TabStop         =   0   'False
         Text            =   "0"
         Top             =   270
         Width           =   1335
      End
      Begin VB.Label Label8 
         AutoSize        =   -1  'True
         Caption         =   "KeyAscii Values:"
         Height          =   195
         Left            =   480
         TabIndex        =   9
         Top             =   930
         Width           =   1170
      End
      Begin VB.Label Label7 
         AutoSize        =   -1  'True
         Caption         =   "2nd character:"
         Height          =   195
         Left            =   615
         TabIndex        =   6
         Top             =   615
         Width           =   1035
      End
      Begin VB.Label Label6 
         AutoSize        =   -1  'True
         Caption         =   "1st character:"
         Height          =   195
         Left            =   675
         TabIndex        =   5
         Top             =   315
         Width           =   975
      End
   End
   Begin VB.CommandButton Command1 
      Caption         =   "&Exit"
      Height          =   450
      Left            =   1480
      TabIndex        =   0
      TabStop         =   0   'False
      Top             =   5520
      Width           =   1300
   End
   Begin VB.Label Label1 
      AutoSize        =   -1  'True
      Caption         =   "Enter a Character (letter, number, punctuation, or symbol) :"
      Height          =   195
      Left            =   75
      TabIndex        =   1
      Top             =   210
      Width           =   4110
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private i As Byte
Private ButtonNum As Byte
Private shiftMask As String
Private shiftActive As Boolean
Private CTRLisDown As Boolean

'when a user selects from the combo list manually change the other values
Private Sub Combo1_Click()
Select Case Combo1.ListIndex
 Case 0 'vbKeyLButton
  Text2.Text = "N/A"
  Text3.Text = "1"
  Text1.MaxLength = 6
  Text1.Text = "LMOUSE"
 Case 1 'vbKeyRButton
  Text2.Text = "N/A"
  Text3.Text = "2"
  Text1.MaxLength = 6
  Text1.Text = "RMOUSE"
 Case 2 'vbKeyCancel
  Text2.Text = "N/A"
  Text3.Text = "3"
  Text1.MaxLength = 6
  Text1.Text = "CANCEL"
 Case 3 'vbKeyMButton
  Text2.Text = "N/A"
  Text3.Text = "4"
  Text1.MaxLength = 6
  Text1.Text = "MMOUSE"
 Case 4 'vbKeyBack
  Text2.Text = "8"
  Text3.Text = "8"
  Text1.MaxLength = 9
  Text1.Text = "BACKSPACE"
 Case 5 'vbKeyTab
  Text2.Text = "9"
  Text3.Text = "9"
  Text1.MaxLength = 3
  Text1.Text = "TAB"
 Case 6 'vbKeyClear
  Text2.Text = "N/A"
  Text3.Text = "12"
  Text1.MaxLength = 5
  Text1.Text = "CLEAR"
 Case 7 'vbKeyReturn
  Text2.Text = "13"
  Text3.Text = "13"
  Text1.MaxLength = 6
  Text1.Text = "RETURN"
 Case 8 'vbKeyShift
  Text2.Text = "N/A"
  Text3.Text = "16"
  Text1.MaxLength = 5
  Text1.Text = "SHIFT"
  If Not shiftMask = "" Then GoTo QuickExit3
 Case 9 'vbKeyControl
  Text2.Text = "N/A"
  Text3.Text = "17"
  Text1.MaxLength = 4
  Text1.Text = "CTRL"
  If Not shiftMask = "" Then GoTo QuickExit3
 Case 10 'vbKeyMenu
  Text2.Text = "N/A"
  Text3.Text = "18"
  Text1.MaxLength = 3
  Text1.Text = "ALT"
  If Not shiftMask = "" Then GoTo QuickExit3
 Case 11 'vbKeyPause
  Text2.Text = "N/A"
  Text3.Text = "19"
  Text1.MaxLength = 5
  Text1.Text = "PAUSE"
 Case 12 'vbKeyCapital
  Text2.Text = "N/A"
  Text3.Text = "20"
  Text1.MaxLength = 8
  Text1.Text = "CAPSLOCK"
 Case 13 'vbKeyEscape
  Text2.Text = "27"
  Text3.Text = "27"
  Text1.MaxLength = 3
  Text1.Text = "ESC"
 Case 14 'vbKeySpace
  Text2.Text = "32"
  Text3.Text = "32"
  Text1.MaxLength = 5
  Text1.Text = "SPACE"
 Case 15 'vbKeyPageUp
  Text2.Text = "N/A"
  Text3.Text = "33"
  Text1.MaxLength = 4
  Text1.Text = "PGUP"
 Case 16 'vbKeyPageDown
  Text2.Text = "N/A"
  Text3.Text = "34"
  Text1.MaxLength = 4
  Text1.Text = "PGDN"
 Case 17 'vbKeyEnd
  Text2.Text = "N/A"
  Text3.Text = "35"
  Text1.MaxLength = 3
  Text1.Text = "END"
 Case 18 'vbKeyHome
  Text2.Text = "N/A"
  Text3.Text = "36"
  Text1.MaxLength = 4
  Text1.Text = "HOME"
 Case 19 'vbKeyLeft
  Text2.Text = "N/A"
  Text3.Text = "37"
  Text1.MaxLength = 4
  Text1.Text = "LEFT"
 Case 20 'vbKeyUp
  Text2.Text = "N/A"
  Text3.Text = "38"
  Text1.MaxLength = 2
  Text1.Text = "UP"
 Case 21 'vbKeyRight
  Text2.Text = "N/A"
  Text3.Text = "39"
  Text1.MaxLength = 5
  Text1.Text = "RIGHT"
 Case 22 'vbKeyDown
  Text2.Text = "N/A"
  Text3.Text = "40"
  Text1.MaxLength = 4
  Text1.Text = "DOWN"
 Case 23 'vbKeySelect
  Text2.Text = "N/A"
  Text3.Text = "41"
  Text1.MaxLength = 6
  Text1.Text = "SELECT"
 Case 24 'vbKeyPrint
  Text2.Text = "N/A"
  Text3.Text = "42"
  Text1.MaxLength = 5
  Text1.Text = "PRINT"
 Case 25 'vbKeyExecute
  Text2.Text = "N/A"
  Text3.Text = "43"
  Text1.MaxLength = 7
  Text1.Text = "EXECUTE"
 Case 26 'vbKeySnapshot
  Text2.Text = "N/A"
  Text3.Text = "44"
  Text1.MaxLength = 8
  Text1.Text = "PRINTSCR"
 Case 27 'vbKeyInsert
  Text2.Text = "N/A"
  Text3.Text = "45"
  Text1.MaxLength = 6
  Text1.Text = "INSERT"
 Case 28 'vbKeyDelete
  Text2.Text = "N/A"
  Text3.Text = "46"
  Text1.MaxLength = 6
  Text1.Text = "DELETE"
 Case 29 'vbKeyHelp
  Text2.Text = "N/A"
  Text3.Text = "47"
  Text1.MaxLength = 4
  Text1.Text = "HELP"
 Case 30 To 39 'numbers (on top of letters)
  Text2.Text = Combo1.ListIndex + 18
  Text3.Text = Combo1.ListIndex + 18
  Text1.MaxLength = 1
  Text1.Text = Chr(Combo1.ListIndex + 18)
 Case 40 To 65 'letters
  Text2.Text = Combo1.ListIndex + 25
  Text3.Text = Combo1.ListIndex + 25
  Text1.MaxLength = 1
  If Text1.Text <> "ALT" And Text1.Text <> "CTRL" Then
   Text1.Text = UCase(Chr(Combo1.ListIndex + 25))
  Else
   Text1.Text = LCase(Chr(Combo1.ListIndex + 25))
  End If
 Case 66 'vbKeyNumPad0
  Text2.Text = "48"
  Text3.Text = "96"
  Text1.MaxLength = 1
  Text1.Text = "0"
 Case 67 'vbKeyNumPad1
  Text2.Text = "49"
  Text3.Text = "97"
  Text1.MaxLength = 1
  Text1.Text = "1"
 Case 68 'vbKeyNumPad2
  Text2.Text = "50"
  Text3.Text = "98"
  Text1.MaxLength = 1
  Text1.Text = "2"
 Case 69 'vbKeyNumPad3
  Text2.Text = "51"
  Text3.Text = "99"
  Text1.MaxLength = 1
  Text1.Text = "3"
 Case 70 'vbKeyNumPad4
  Text2.Text = "52"
  Text3.Text = "100"
  Text1.MaxLength = 1
  Text1.Text = "4"
 Case 71 'vbKeyNumPad5
  Text2.Text = "53"
  Text3.Text = "101"
  Text1.MaxLength = 1
  Text1.Text = "5"
 Case 72 'vbKeyNumPad6
  Text2.Text = "54"
  Text3.Text = "102"
  Text1.MaxLength = 1
  Text1.Text = "6"
 Case 73 'vbKeyNumPad7
  Text2.Text = "55"
  Text3.Text = "103"
  Text1.MaxLength = 1
  Text1.Text = "7"
 Case 74 'vbKeyNumPad8
  Text2.Text = "56"
  Text3.Text = "104"
  Text1.MaxLength = 1
  Text1.Text = "8"
 Case 75 'vbKeyNumPad9
  Text2.Text = "57"
  Text3.Text = "105"
  Text1.MaxLength = 1
  Text1.Text = "9"
 Case 76 'vbKeyMultiply
  Text2.Text = "42"
  Text3.Text = "106"
  Text1.MaxLength = 1
  Text1.Text = "*"
 Case 77 'vbKeyAdd
  Text2.Text = "43"
  Text3.Text = "107"
  Text1.MaxLength = 1
  Text1.Text = "+"
 Case 78 'vbKeySeparator
  Text2.Text = "N/A"
  Text3.Text = "108"
  Text1.MaxLength = 8
  Text1.Text = "SEPARATE"
 Case 79 'vbKeySubtract
  Text2.Text = "45"
  Text3.Text = "109"
  Text1.MaxLength = 1
  Text1.Text = "-"
 Case 80 'vbKeyDecimal
  Text2.Text = "46"
  Text3.Text = "110"
  Text1.MaxLength = 1
  Text1.Text = "."
 Case 81 'vbKeyDivide
  Text2.Text = "47"
  Text3.Text = "111"
  Text1.MaxLength = 1
  Text1.Text = "/"
 Case 82 'vbKeyF1
  Text2.Text = "N/A"
  Text3.Text = "112"
  Text1.MaxLength = 2
  Text1.Text = "F1"
 Case 83 'vbKeyF2
  Text2.Text = "N/A"
  Text3.Text = "113"
  Text1.MaxLength = 2
  Text1.Text = "F2"
 Case 84 'vbKeyF3
  Text2.Text = "N/A"
  Text3.Text = "114"
  Text1.MaxLength = 2
  Text1.Text = "F3"
 Case 85 'vbKeyF4
  Text2.Text = "N/A"
  Text3.Text = "115"
  Text1.MaxLength = 2
  Text1.Text = "F4"
 Case 86 'vbKeyF5
  Text2.Text = "N/A"
  Text3.Text = "116"
  Text1.MaxLength = 2
  Text1.Text = "F5"
 Case 87 'vbKeyF6
  Text2.Text = "N/A"
  Text3.Text = "117"
  Text1.MaxLength = 2
  Text1.Text = "F6"
 Case 88 'vbKeyF7
  Text2.Text = "N/A"
  Text3.Text = "118"
  Text1.MaxLength = 2
  Text1.Text = "F7"
 Case 89 'vbKeyF8
  Text2.Text = "N/A"
  Text3.Text = "119"
  Text1.MaxLength = 2
  Text1.Text = "F8"
 Case 90 'vbKeyF9
  Text2.Text = "N/A"
  Text3.Text = "120"
  Text1.MaxLength = 2
  Text1.Text = "F9"
 Case 91 'vbKeyF10
  Text2.Text = "N/A"
  Text3.Text = "121"
  Text1.MaxLength = 3
  Text1.Text = "F10"
 Case 92 'vbKeyF11
  Text2.Text = "N/A"
  Text3.Text = "122"
  Text1.MaxLength = 3
  Text1.Text = "F11"
 Case 93 'vbKeyF12
  Text2.Text = "N/A"
  Text3.Text = "123"
  Text1.MaxLength = 3
  Text1.Text = "F12"
 Case 94 'vbKeyF13
  Text2.Text = "N/A"
  Text3.Text = "124"
  Text1.MaxLength = 3
  Text1.Text = "F13"
 Case 95 'vbKeyF14
  Text2.Text = "N/A"
  Text3.Text = "125"
  Text1.MaxLength = 3
  Text1.Text = "F14"
 Case 96 'vbKeyF15
  Text2.Text = "N/A"
  Text3.Text = "126"
  Text1.MaxLength = 3
  Text1.Text = "F15"
 Case 97 'vbKeyF16
  Text2.Text = "N/A"
  Text3.Text = "127"
  Text1.MaxLength = 3
  Text1.Text = "F16"
 Case 98 'vbKeyNumlock
  Text2.Text = "N/A"
  Text3.Text = "144"
  Text1.MaxLength = 7
  Text1.Text = "NUMLOCK"
End Select
Text4.Text = Text1.Text
QuickExit3:
End Sub

Private Sub UpDown1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
 ButtonNum = 2
 Timer1.Interval = 200
 Timer1.Enabled = True
 Timer2.Enabled = True
End Sub

Private Sub UpDown2_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
 ButtonNum = 4
 Timer1.Interval = 200
 Timer1.Enabled = True
 Timer2.Enabled = True
End Sub

Private Sub UpDown3_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
 ButtonNum = 6
 Timer1.Interval = 200
 Timer1.Enabled = True
 Timer2.Enabled = True
End Sub

Private Sub UpDown4_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
 ButtonNum = 8
 Timer1.Interval = 200
 Timer1.Enabled = True
 Timer2.Enabled = True
End Sub

Private Sub UpDown1_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
 Timer1.Enabled = False
 Timer2.Enabled = False
 Timer1.Interval = 200
 ButtonNum = 0
End Sub

Private Sub UpDown2_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
 Timer1.Enabled = False
 Timer2.Enabled = False
 Timer1.Interval = 200
 ButtonNum = 0
End Sub

Private Sub UpDown3_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
 Timer1.Enabled = False
 Timer2.Enabled = False
 Timer1.Interval = 200
 ButtonNum = 0
End Sub

Private Sub UpDown4_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
 Timer1.Enabled = False
 Timer2.Enabled = False
 Timer1.Interval = 200
 ButtonNum = 0
End Sub

'1st KeyAscii Character Increase Button Pressed
Private Sub UpDown1_UpClick()
 UpDown1.Tag = "up"
 If Mid(Text7.Text, 1, 3) = "N/A" Then
  'Text7 says N/A so make it a 255 (upper-most value)
  Text7.Text = "48 to " & WriteKeyAsciiFromChar(Text6.Text)
  Text5.MaxLength = 1
  Text5.Text = "0"
 Else
 'Text7 does not say N/A, so increase number by 1
  If Val(Mid(Text7.Text, 1, 3)) = 255 Then
   Text7.Text = "255 to " & WriteKeyAsciiFromChar(Text6.Text)
   Text5.MaxLength = 1
   Text5.Text = "ÿ"
  Else
   Text7.Text = Val(Mid(Text7.Text, 1, 3)) + 1 & " to " & WriteKeyAsciiFromChar(Text6.Text)
   Text5.MaxLength = Len(WriteCharFromKeyAscii(Val(Trim(Mid(Text7.Text, 1, 3)))))
   Text5.Text = WriteCharFromKeyAscii(Val(Trim(Mid(Text7.Text, 1, 3))))
  End If
 End If
 Text5.SelStart = 0
 Text5.SelLength = Len(Text5.Text)
 Text5.SetFocus
End Sub

'2nd KeyAscii Character Increase Button Pressed
Private Sub UpDown2_UpClick()
 UpDown2.Tag = "up"
 If Mid(Text7.Text, Len(Text7.Text) - 2, 3) = "N/A" Then
  Text7.Text = WriteKeyAsciiFromChar(Text5.Text) & " to " & "57"
  Text6.MaxLength = 1
  Text6.Text = "9"
 Else
 'Text7 does not say N/A, so increase number by 1
  If Mid(Text7.Text, Len(Text7.Text) - 2, 1) = "o" Then 'single digit number
    Text7.Text = WriteKeyAsciiFromChar(Text5.Text) & " to " & Val(Mid(Text7.Text, Len(Text7.Text) - 1, 2)) + 1
    Text6.MaxLength = Len(WriteCharFromKeyAscii(Val(Trim(Mid(Text7.Text, Len(Text7.Text) - 1, 2)))))
    Text6.Text = WriteCharFromKeyAscii(Val(Trim(Mid(Text7.Text, Len(Text7.Text) - 1, 2))))
  Else
   If Mid(Text7.Text, Len(Text7.Text) - 2, 3) = "255" Then
    Text7.Text = WriteKeyAsciiFromChar(Text5.Text) & " to " & "255"
    Text6.MaxLength = 1
    Text6.Text = "ÿ"
   Else
    Text7.Text = WriteKeyAsciiFromChar(Text5.Text) & " to " & Val(Mid(Text7.Text, Len(Text7.Text) - 2, 3)) + 1
    Text6.MaxLength = Len(WriteCharFromKeyAscii(Val(Trim(Mid(Text7.Text, Len(Text7.Text) - 2, 3)))))
    Text6.Text = WriteCharFromKeyAscii(Val(Trim(Mid(Text7.Text, Len(Text7.Text) - 2, 3))))
   End If
  End If
 End If
 Text6.SelStart = 0
 Text6.SelLength = Len(Text6.Text)
 Text6.SetFocus
End Sub

'1st KeyCode Character Increase Button Pressed
Private Sub UpDown3_UpClick()
 UpDown3.Tag = "up"
 If Mid(Text10.Text, 1, 3) = "N/A" Then
  'Text10 says N/A so make it a 255 (upper-most value)
  Text10.Text = "65 to " & WriteKeyCodeFromChar(Text9.Text)
  Text8.MaxLength = 1
  Text8.Text = "A"
 Else
 'Text10 does not say N/A, so increase number by 1
  If Val(Mid(Text10.Text, 1, 3)) = 255 Then
   Text10.Text = "255 to " & WriteKeyCodeFromChar(Text9.Text)
   Text8.MaxLength = 4
   Text8.Text = "MISC"
  Else
   Text10.Text = Val(Mid(Text10.Text, 1, 3)) + 1 & " to " & WriteKeyCodeFromChar(Text9.Text)
   Text8.MaxLength = Len(WriteCharFromKeyCode(Val(Mid(Text10.Text, 1, 3)), IsShiftCharacter(Text8.Text)))
   Text8.Text = WriteCharFromKeyCode(Val(Trim(Mid(Text10.Text, 1, 3))), IsShiftCharacter(Text8.Text))
  End If
 End If
 Text8.SelStart = 0
 Text8.SelLength = Len(Text8.Text)
 Text8.SetFocus
End Sub

'2nd KeyCode Character Increase Button Pressed
Private Sub UpDown4_UpClick()
 UpDown4.Tag = "up"
 If Mid(Text10.Text, Len(Text10.Text) - 2, 3) = "N/A" Then
  Text10.Text = WriteKeyCodeFromChar(Text8.Text) & " to " & "90"
  Text9.MaxLength = 1
  Text9.Text = "Z"
 Else
 'Text10 does not say N/A, so increase number by 1
  If Mid(Text10.Text, Len(Text10.Text) - 2, 1) = "o" Then 'single digit number
    Text10.Text = WriteKeyCodeFromChar(Text8.Text) & " to " & Val(Mid(Text10.Text, Len(Text10.Text) - 1, 2)) + 1
    Text9.MaxLength = Len(WriteCharFromKeyCode(Val(Trim(Mid(Text10.Text, Len(Text10.Text) - 1, 2))), IsShiftCharacter(Text9.Text)))
    Text9.Text = WriteCharFromKeyCode(Val(Trim(Mid(Text10.Text, Len(Text10.Text) - 1, 2))), IsShiftCharacter(Text9.Text))
  Else
   If Mid(Text10.Text, Len(Text10.Text) - 2, 3) = "255" Then
    Text10.Text = WriteKeyCodeFromChar(Text8.Text) & " to " & "255"
    Text9.MaxLength = 4
    Text9.Text = "MISC"
   Else
    Text10.Text = WriteKeyCodeFromChar(Text8.Text) & " to " & Val(Mid(Text10.Text, Len(Text10.Text) - 2, 3)) + 1
    Text9.MaxLength = Len(WriteCharFromKeyCode(Val(Trim(Mid(Text10.Text, Len(Text10.Text) - 2, 3))), IsShiftCharacter(Text9.Text)))
    Text9.Text = WriteCharFromKeyCode(Val(Trim(Mid(Text10.Text, Len(Text10.Text) - 2, 3))), IsShiftCharacter(Text9.Text))
   End If
  End If
 End If
 Text9.SelStart = 0
 Text9.SelLength = Len(Text9.Text)
 Text9.SetFocus
End Sub

'1st KeyAscii Character Decrease Button Pressed
Private Sub UpDown1_DownClick()
 UpDown1.Tag = "down"
 If Mid(Text7.Text, 1, 3) = "N/A" Then
 'Text7 says N/A so make it a 0
 Text7.Text = "48 to " & WriteKeyAsciiFromChar(Text6.Text)
 Text5.MaxLength = 1
 Text5.Text = "0"
 Else
 'Text7 does not say N/A, so decrease number by 1
  If Val(Mid(Text7.Text, 1, 3)) = 0 Then
   Text7.Text = "0 to " & WriteKeyAsciiFromChar(Text6.Text)
   Text5.MaxLength = 4
   Text5.Text = "NULL"
  Else
   Text7.Text = Val(Mid(Text7.Text, 1, 3)) - 1 & " to " & WriteKeyAsciiFromChar(Text6.Text)
   Text5.MaxLength = Len(WriteCharFromKeyAscii(Val(Trim(Mid(Text7.Text, 1, 3)))))
   Text5.Text = WriteCharFromKeyAscii(Val(Trim(Mid(Text7.Text, 1, 3))))
  End If
 End If
 Text5.SelStart = 0
 Text5.SelLength = Len(Text5.Text)
 Text5.SetFocus
End Sub

'2nd KeyAscii Character Decrease Button Pressed
Private Sub UpDown2_DownClick()
 UpDown2.Tag = "down"
 If Mid(Text7.Text, Len(Text7.Text) - 2, 3) = "N/A" Then
  'Text7 says N/A so make it a 0
  Text7.Text = WriteKeyAsciiFromChar(Text5.Text) & " to " & "57"
  Text6.MaxLength = 1
  Text6.Text = "9"
 Else
  If Mid(Text7.Text, Len(Text7.Text) - 2, 1) = "o" Or Mid(Text7.Text, Len(Text7.Text) - 4, 5) = "to 10" Then
    'Text7 does not say N/A, so decrease number by 1
    If Mid(Text7.Text, Len(Text7.Text) - 1, 2) = " 0" Then
     Text7.Text = WriteKeyAsciiFromChar(Text5.Text) & " to " & "0"
     Text6.MaxLength = 4
     Text6.Text = "NULL"
    Else
     Text7.Text = WriteKeyAsciiFromChar(Text5.Text) & " to " & Val(Mid(Text7.Text, Len(Text7.Text) - 1, 2)) - 1
     Text6.MaxLength = Len(WriteCharFromKeyAscii(Val(Trim(Mid(Text7.Text, Len(Text7.Text) - 1, 2)))))
     Text6.Text = WriteCharFromKeyAscii(Val(Trim(Mid(Text7.Text, Len(Text7.Text) - 1, 2))))
    End If
  Else
   'Text7 does not say N/A, so decrease number by 1
   If Mid(Text7.Text, Len(Text7.Text) - 1, 2) = " 0" Then
    Text7.Text = WriteKeyAsciiFromChar(Text5.Text) & " to " & "0"
    Text6.MaxLength = 4
    Text6.Text = "NULL"
   Else
    Text7.Text = WriteKeyAsciiFromChar(Text5.Text) & " to " & Val(Mid(Text7.Text, Len(Text7.Text) - 2, 3)) - 1
    Text6.MaxLength = Len(WriteCharFromKeyAscii(Val(Trim(Mid(Text7.Text, Len(Text7.Text) - 2, 3)))))
    Text6.Text = WriteCharFromKeyAscii(Val(Trim(Mid(Text7.Text, Len(Text7.Text) - 2, 3))))
   End If
  End If
 End If
 Text6.SelStart = 0
 Text6.SelLength = Len(Text6.Text)
 Text6.SetFocus
End Sub

'1st KeyCode Character Decrease Button Pressed
Private Sub UpDown3_DownClick()
 UpDown3.Tag = "down"
 If Mid(Text10.Text, 1, 3) = "N/A" Then
  'Text10 says N/A so make it a 0
  Text10.Text = "65 to " & WriteKeyCodeFromChar(Text9.Text)
  Text8.MaxLength = 1
  Text8.Text = "A"
 Else
  'Text10 does not say N/A, so decrease number by 1
  If Val(Mid(Text10.Text, 1, 3)) = 0 Then
   Text10.Text = "0 to " & WriteKeyCodeFromChar(Text9.Text)
   Text8.MaxLength = 6
   Text8.Text = "NO KEY"
  Else
   Text10.Text = Val(Mid(Text10.Text, 1, 3)) - 1 & " to " & WriteKeyCodeFromChar(Text9.Text)
   Text8.MaxLength = Len(WriteCharFromKeyCode(Val(Trim(Mid(Text10.Text, 1, 3))), IsShiftCharacter(Text8.Text)))
   Text8.Text = WriteCharFromKeyCode(Val(Trim(Mid(Text10.Text, 1, 3))), IsShiftCharacter(Text8.Text))
  End If
 End If
 Text8.SelStart = 0
 Text8.SelLength = Len(Text8.Text)
 Text8.SetFocus
End Sub

'2nd KeyCode Character Decrease Button Pressed
Private Sub UpDown4_DownClick()
 UpDown4.Tag = "down"
 If Mid(Text10.Text, Len(Text10.Text) - 2, 3) = "N/A" Then
  'Text10 says N/A so make it a 0
  Text10.Text = WriteKeyCodeFromChar(Text8.Text) & " to " & "90"
  Text9.MaxLength = 1
  Text9.Text = "Z"
 Else
  If Mid(Text10.Text, Len(Text10.Text) - 2, 1) = "o" Or Mid(Text10.Text, Len(Text10.Text) - 4, 5) = "to 10" Then
    'Text10 does not say N/A, so decrease number by 1
    If Mid(Text10.Text, Len(Text10.Text) - 1, 2) = " 0" Then
     Text10.Text = WriteKeyCodeFromChar(Text8.Text) & " to " & "0"
     Text9.MaxLength = 6
     Text9.Text = "NO KEY"
    Else
     Text10.Text = WriteKeyCodeFromChar(Text8.Text) & " to " & Val(Mid(Text10.Text, Len(Text10.Text) - 1, 2)) - 1
     Text9.MaxLength = Len(WriteCharFromKeyCode(Val(Trim(Mid(Text10.Text, Len(Text10.Text) - 1, 2))), IsShiftCharacter(Text9.Text)))
     Text9.Text = WriteCharFromKeyCode(Val(Trim(Mid(Text10.Text, Len(Text10.Text) - 1, 2))), IsShiftCharacter(Text9.Text))
    End If
  Else
   'Text10 does not say N/A, so decrease number by 1
   If Mid(Text10.Text, Len(Text10.Text) - 1, 2) = " 0" Then
    Text10.Text = WriteKeyCodeFromChar(Text8.Text) & " to " & "0"
    Text9.MaxLength = 6
    Text9.Text = "NO KEY"
   Else
    Text10.Text = WriteKeyCodeFromChar(Text8.Text) & " to " & Val(Mid(Text10.Text, Len(Text10.Text) - 2, 3)) - 1
    Text9.MaxLength = Len(WriteCharFromKeyCode(Val(Trim(Mid(Text10.Text, Len(Text10.Text) - 2, 3))), IsShiftCharacter(Text9.Text)))
    Text9.Text = WriteCharFromKeyCode(Val(Trim(Mid(Text10.Text, Len(Text10.Text) - 2, 3))), IsShiftCharacter(Text9.Text))
   End If
  End If
 End If
 Text9.SelStart = 0
 Text9.SelLength = Len(Text9.Text)
 Text9.SetFocus
End Sub

Private Sub Timer2_Timer()
 If Timer1.Interval > 40 Then
   Timer1.Interval = Timer1.Interval - 15
 Else
   Timer2.Enabled = False
 End If
End Sub

Private Sub Timer1_Timer()
 Select Case ButtonNum
 Case 2
  If UpDown1.Tag = "up" Then
   Call UpDown1_UpClick
  ElseIf UpDown1.Tag = "down" Then
   Call UpDown1_DownClick
  End If
 Case 4
  If UpDown2.Tag = "up" Then
   Call UpDown2_UpClick
  ElseIf UpDown2.Tag = "down" Then
   Call UpDown2_DownClick
  End If
 Case 6
  If UpDown3.Tag = "up" Then
   Call UpDown3_UpClick
  ElseIf UpDown3.Tag = "down" Then
   Call UpDown3_DownClick
  End If
 Case 8
  If UpDown4.Tag = "up" Then
   Call UpDown4_UpClick
  ElseIf UpDown4.Tag = "down" Then
   Call UpDown4_DownClick
  End If
 Case Else
  Timer1.Enabled = False
 End Select
End Sub

Private Sub Text8_KeyDown(KeyCode As Integer, Shift As Integer)
 Text10.Text = KeyCode & " to " & WriteKeyCodeFromChar(Text9.Text)
 CTRLisDown = False
 If KeyCode = 17 Then CTRLisDown = True 'CTRL was pressed
 If Shift = 1 Or Shift = 3 Or Shift = 5 Or Shift = 7 Then
  Text8.MaxLength = Len(WriteCharFromKeyCode(KeyCode, True))
  Text8.Text = WriteCharFromKeyCode(KeyCode, True)
 Else
  Text8.MaxLength = Len(WriteCharFromKeyCode(KeyCode, False))
  Text8.Text = WriteCharFromKeyCode(KeyCode, False)
 End If
 If KeyCode = 8 And Shift = 2 Then Text8.Text = "DELETE" 'CTRL + BACKSPACE = DELETE
End Sub

Private Sub Text9_KeyDown(KeyCode As Integer, Shift As Integer)
 Text10.Text = WriteKeyCodeFromChar(Text8.Text) & " to " & KeyCode
 CTRLisDown = False
 If KeyCode = 17 Then CTRLisDown = True 'CTRL was pressed
 If Shift = 1 Or Shift = 3 Or Shift = 5 Or Shift = 7 Then
  Text9.MaxLength = Len(WriteCharFromKeyCode(KeyCode, True))
  Text9.Text = WriteCharFromKeyCode(KeyCode, True)
 Else
  Text9.MaxLength = Len(WriteCharFromKeyCode(KeyCode, False))
  Text9.Text = WriteCharFromKeyCode(KeyCode, False)
 End If
 If KeyCode = 8 And Shift = 2 Then Text9.Text = "DELETE" 'CTRL + BACKSPACE = DELETE
End Sub

Private Sub Form_Activate()

'fill up the combo box with items
Combo1.Clear
Combo1.AddItem "vbKeyLButton", 0
Combo1.AddItem "vbKeyRButton", 1
Combo1.AddItem "vbKeyCancel", 2
Combo1.AddItem "vbKeyMButton", 3
Combo1.AddItem "vbKeyBack", 4
Combo1.AddItem "vbKeyTab", 5
Combo1.AddItem "vbKeyClear", 6
Combo1.AddItem "vbKeyReturn", 7
Combo1.AddItem "vbKeyShift", 8
Combo1.AddItem "vbKeyControl", 9
Combo1.AddItem "vbKeyMenu", 10
Combo1.AddItem "vbKeyPause", 11
Combo1.AddItem "vbKeyCapital", 12
Combo1.AddItem "vbKeyEscape", 13
Combo1.AddItem "vbKeySpace", 14
Combo1.AddItem "vbKeyPageUp", 15
Combo1.AddItem "vbKeyPageDown", 16
Combo1.AddItem "vbKeyEnd", 17
Combo1.AddItem "vbKeyHome", 18
Combo1.AddItem "vbKeyLeft", 19
Combo1.AddItem "vbKeyUp", 20
Combo1.AddItem "vbKeyRight", 21
Combo1.AddItem "vbKeyDown", 22
Combo1.AddItem "vbKeySelect", 23
Combo1.AddItem "vbKeyPrint", 24
Combo1.AddItem "vbKeyExecute", 25
Combo1.AddItem "vbKeySnapshot", 26
Combo1.AddItem "vbKeyInsert", 27
Combo1.AddItem "vbKeyDelete", 28
Combo1.AddItem "vbKeyHelp", 29
Combo1.AddItem "vbKey0", 30
Combo1.AddItem "vbKey1", 31
Combo1.AddItem "vbKey2", 32
Combo1.AddItem "vbKey3", 33
Combo1.AddItem "vbKey4", 34
Combo1.AddItem "vbKey5", 35
Combo1.AddItem "vbKey6", 36
Combo1.AddItem "vbKey7", 37
Combo1.AddItem "vbKey8", 38
Combo1.AddItem "vbKey9", 39
Combo1.AddItem "vbKeyA", 40
Combo1.AddItem "vbKeyB", 41
Combo1.AddItem "vbKeyC", 42
Combo1.AddItem "vbKeyD", 43
Combo1.AddItem "vbKeyE", 44
Combo1.AddItem "vbKeyF", 45
Combo1.AddItem "vbKeyG", 46
Combo1.AddItem "vbKeyH", 47
Combo1.AddItem "vbKeyI", 48
Combo1.AddItem "vbKeyJ", 49
Combo1.AddItem "vbKeyK", 50
Combo1.AddItem "vbKeyL", 51
Combo1.AddItem "vbKeyM", 52
Combo1.AddItem "vbKeyN", 53
Combo1.AddItem "vbKeyO", 54
Combo1.AddItem "vbKeyP", 55
Combo1.AddItem "vbKeyQ", 56
Combo1.AddItem "vbKeyR", 57
Combo1.AddItem "vbKeyS", 58
Combo1.AddItem "vbKeyT", 59
Combo1.AddItem "vbKeyU", 60
Combo1.AddItem "vbKeyV", 61
Combo1.AddItem "vbKeyW", 62
Combo1.AddItem "vbKeyX", 63
Combo1.AddItem "vbKeyY", 64
Combo1.AddItem "vbKeyZ", 65
Combo1.AddItem "vbKeyNumPad0", 66
Combo1.AddItem "vbKeyNumPad1", 67
Combo1.AddItem "vbKeyNumPad2", 68
Combo1.AddItem "vbKeyNumPad3", 69
Combo1.AddItem "vbKeyNumPad4", 70
Combo1.AddItem "vbKeyNumPad5", 71
Combo1.AddItem "vbKeyNumPad6", 72
Combo1.AddItem "vbKeyNumPad7", 73
Combo1.AddItem "vbKeyNumPad8", 74
Combo1.AddItem "vbKeyNumPad9", 75
Combo1.AddItem "vbKeyMultiply", 76
Combo1.AddItem "vbKeyAdd", 77
Combo1.AddItem "vbKeySeparator", 78
Combo1.AddItem "vbKeySubtract", 79
Combo1.AddItem "vbKeyDecimal", 80
Combo1.AddItem "vbKeyDivide", 81
Combo1.AddItem "vbKeyF1", 82
Combo1.AddItem "vbKeyF2", 83
Combo1.AddItem "vbKeyF3", 84
Combo1.AddItem "vbKeyF4", 85
Combo1.AddItem "vbKeyF5", 86
Combo1.AddItem "vbKeyF6", 87
Combo1.AddItem "vbKeyF7", 88
Combo1.AddItem "vbKeyF8", 89
Combo1.AddItem "vbKeyF9", 90
Combo1.AddItem "vbKeyF10", 91
Combo1.AddItem "vbKeyF11", 92
Combo1.AddItem "vbKeyF12", 93
Combo1.AddItem "vbKeyF13", 94
Combo1.AddItem "vbKeyF14", 95
Combo1.AddItem "vbKeyF15", 96
Combo1.AddItem "vbKeyF16", 97
Combo1.AddItem "vbKeyNumlock", 98

'set the opening values
Combo1.ListIndex = 40
Text1.Text = "a"
Text2.Text = "97"
Text3.Text = "65"
Text4.Text = "a"
Text1.SetFocus

End Sub

Private Sub Text1_Change()
 Text1.SelStart = 0
 Text1.SelLength = Len(Text1.Text)
End Sub

Private Sub Text1_GotFocus()
 Text1.MaxLength = 1
 Text1.SelStart = 0
 Text1.SelLength = Len(Text1.Text)
End Sub

Private Sub findTheShift(theShift As Integer)
 If Not theShift = 0 Then
  shiftActive = True
 Else
  shiftActive = False
 End If
 Select Case theShift
 Case 0
  shiftMask = ""
 Case 1
  shiftMask = "SHIFT + "
 Case 2
  shiftMask = "CTRL + "
 Case 3
  shiftMask = "SHIFT + CTRL + "
 Case 4
  shiftMask = "ALT + "
 Case 5
  shiftMask = "SHIFT + ALT + "
 Case 6
  shiftMask = "CTRL + ALT + "
 Case 7
  shiftMask = "SHIFT + CTRL + ALT + "
 End Select
End Sub

Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
Text3.Text = KeyCode 'fills in the key code box

If KeyCode = 17 Then CTRLisDown = True 'CTRL was pressed
If Shift = 1 Or Shift = 3 Or Shift = 5 Or Shift = 7 Then
 Text1.MaxLength = Len(WriteCharFromKeyCode(KeyCode, True))
 Text1.Text = WriteCharFromKeyCode(KeyCode, True)
 Text2.Text = WriteKeyAsciiFromKeyCode(KeyCode, True) 'KeyAscii Text Box
Else
 Text1.MaxLength = Len(WriteCharFromKeyCode(KeyCode, False))
 Text1.Text = WriteCharFromKeyCode(KeyCode, False)
 Text2.Text = WriteKeyAsciiFromKeyCode(KeyCode, False) 'KeyAscii Text Box
End If

If KeyCode = 8 And Shift = 2 Then Text1.Text = "DELETE" 'CTRL + BACKSPACE = DELETE

Combo1.Text = ConstantFromKeyCode(KeyCode)
Call findTheShift(Shift)
 If KeyCode <> 16 And KeyCode <> 17 And KeyCode <> 18 Then
     Text4.Text = shiftMask + UCase(WriteCharFromKeyCode(KeyCode, False))
 Else
 Text4.Text = WriteCharFromKeyCode(KeyCode, False)
 End If
If shiftActive = True Then GoTo QuickExit2

Text4.Text = Text1.Text

QuickExit2:
'when certain keys are pressed (such as ALT) it takes focus away from the
'text box, the following line prevents that from happening
KeyCode = 0 'cancel the key press (don't send it to system)

End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)

Text1.MaxLength = Len(WriteCharFromKeyAscii(KeyAscii))
Text1.Text = WriteCharFromKeyAscii(KeyAscii)

If KeyAscii = 42 Or KeyAscii = 43 Or KeyAscii = 45 Or KeyAscii = 46 Or KeyAscii = 47 Then
GoTo QuickExitKeyPress '*, +, -, ., / these could be on number-pad, let keydown figure it out
End If
If KeyAscii >= 48 And KeyAscii <= 57 Then GoTo QuickExitKeyPress 'numbers, let keydown figure it out

Combo1.Text = ConstantFromKeyAscii(KeyAscii)
Text3.Text = WriteKeyCodeFromKeyAscii(KeyAscii)

If KeyAscii = 0 And CTRLisDown = True Then 'NUL (null)
 Text4.Text = "CTRL + SHIFT + @"
 GoTo QuickExitKeyPress
End If

If KeyAscii = 30 And CTRLisDown = True Then 'RS (record separator)
 Text4.Text = "CTRL + SHIFT + ^"
 GoTo QuickExitKeyPress
End If

If KeyAscii = 31 And CTRLisDown = True Then 'US (unit separator)
 Text4.Text = "CTRL + SHIFT + _"
 GoTo QuickExitKeyPress
End If

If KeyAscii > 127 Or shiftActive = True Then GoTo QuickExitKeyPress

Text4.Text = Text1.Text

QuickExitKeyPress:
 Text2.Text = KeyAscii 'fills in the key ascii box
 KeyAscii = 0

End Sub

Private Sub Text1_KeyUp(KeyCode As Integer, Shift As Integer)
 If KeyCode = 17 Then CTRLisDown = False
End Sub

Private Sub Text1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
If Button = 1 Then 'left mouse button
 Combo1.ListIndex = 0
ElseIf Button = 2 Then 'right mouse button
 Combo1.ListIndex = 1
Else
 Combo1.ListIndex = 3 'middle mouse button
End If
Text1.SetFocus
End Sub

Private Sub Text2_Change()
 If Left(Text4.Text, 3) = "ALT" Then
  Text4.Text = "ALT + 0" & Text2.Text
 End If
End Sub

Private Sub Text5_Change()
 Text7.Text = WriteKeyAsciiFromChar(Text5.Text) & " to " & WriteKeyAsciiFromChar(Text6.Text)
 Text5.SelStart = 0
 Text5.SelLength = Len(Text5.Text)
End Sub

Private Sub Text5_GotFocus()
 Text5.MaxLength = 1
 Text5.SelStart = 0
 Text5.SelLength = Len(Text5.Text)
End Sub

Private Sub Text5_KeyDown(KeyCode As Integer, Shift As Integer)
 If Shift = 1 Or Shift = 3 Or Shift = 5 Or Shift = 7 Then
  Text5.MaxLength = Len(WriteCharFromKeyCode(KeyCode, True))
  Text5.Text = WriteCharFromKeyCode(KeyCode, True)
 Else
  Text5.MaxLength = Len(WriteCharFromKeyCode(KeyCode, False))
  Text5.Text = WriteCharFromKeyCode(KeyCode, False)
 End If
 If KeyCode = 8 And Shift = 2 Then Text5.Text = "DELETE" 'CTRL + BACKSPACE = DELETE
 Text7.Text = WriteKeyAsciiFromKeyCode(KeyCode, IsShiftDown(Shift)) & " to " & WriteKeyAsciiFromChar(Text6.Text)
 KeyCode = 0 'cancel the key press (don't send it to system)
End Sub

Private Sub Text5_KeyPress(KeyAscii As Integer)
 Text5.MaxLength = Len(WriteCharFromKeyAscii(KeyAscii))
 Text5.Text = WriteCharFromKeyAscii(KeyAscii)
 KeyAscii = 0
End Sub

Private Sub Text5_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
 Text5.SetFocus
 Text5.SelStart = 0
 Text5.SelLength = Len(Text5.Text)
End Sub

Private Sub Text6_Change()
 Text7.Text = WriteKeyAsciiFromChar(Text5.Text) & " to " & WriteKeyAsciiFromChar(Text6.Text)
 Text6.SelStart = 0
 Text6.SelLength = Len(Text6.Text)
End Sub

Private Sub Text6_GotFocus()
 Text6.MaxLength = 1
 Text6.SelStart = 0
 Text6.SelLength = Len(Text6.Text)
End Sub

Private Sub Text6_KeyDown(KeyCode As Integer, Shift As Integer)
 If Shift = 1 Or Shift = 3 Or Shift = 5 Or Shift = 7 Then
  Text6.MaxLength = Len(WriteCharFromKeyCode(KeyCode, True))
  Text6.Text = WriteCharFromKeyCode(KeyCode, True)
 Else
  Text6.MaxLength = Len(WriteCharFromKeyCode(KeyCode, False))
  Text6.Text = WriteCharFromKeyCode(KeyCode, False)
 End If
 If KeyCode = 8 And Shift = 2 Then Text6.Text = "DELETE" 'CTRL + BACKSPACE = DELETE
 Text7.Text = WriteKeyAsciiFromChar(Text5.Text) & " to " & WriteKeyAsciiFromKeyCode(KeyCode, IsShiftDown(Shift))
 KeyCode = 0 'cancel the key press (don't send it to system)
End Sub

Private Sub Text6_KeyPress(KeyAscii As Integer)
 Text6.MaxLength = Len(WriteCharFromKeyAscii(KeyAscii))
 Text6.Text = WriteCharFromKeyAscii(KeyAscii)
 KeyAscii = 0
End Sub

Private Sub Text6_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
 Text6.SetFocus
 Text6.SelStart = 0
 Text6.SelLength = Len(Text6.Text)
End Sub

Private Sub Text8_Change()
 Text8.SelStart = 0
 Text8.SelLength = Len(Text8.Text)
End Sub

Private Sub Text8_GotFocus()
 Text8.SelStart = 0
 Text8.SelLength = Len(Text8.Text)
End Sub

Private Sub Text9_Change()
 Text9.SelStart = 0
 Text9.SelLength = Len(Text9.Text)
End Sub

Private Sub Text9_GotFocus()
 Text9.SelStart = 0
 Text9.SelLength = Len(Text9.Text)
End Sub

Friend Function WindowProc(ByVal sHwnd As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
 Select Case uMsg
  Case WM_RBUTTONUP
  ' Right button was clicked. Consume the right click message before the textbox gets it.
  ' You can insert a Popup menu of your own choice here. Fx.
  ' Popupmenu mnuPopup
  ReleaseCapture
  Exit Function
 End Select
 WindowProc = CallWindowProc(mWndProcNext, sHwnd, uMsg, wParam, ByVal lParam)
End Function

Private Sub Command1_Click()
 Unload Me
End Sub

Private Sub Form_Load()
 SubClass Text1.hwnd 'Start subclassing the Textbox
 SubClass Text5.hwnd
 SubClass Text6.hwnd
 SetReadOnly Combo1, True 'set combo1 to read only
End Sub

Private Sub Form_Unload(Cancel As Integer)
 UnSubClass
 Timer1.Enabled = False
 Timer2.Enabled = False
End Sub

Private Sub UnSubClass()
 If mWndProcNext Then
  SetWindowLong Me.hwnd, GWL_WNDPROC, mWndProcNext
 End If
End Sub

Private Sub SubClass(sHwnd)
 Dim lResult As Long
 UnSubClass
 mWndProcNext = SetWindowLong(sHwnd, GWL_WNDPROC, AddressOf SubWndProc)
 If mWndProcNext Then
  lResult = SetWindowLong(sHwnd, GWL_USERDATA, ObjPtr(Me))
 End If
End Sub