16,720
社区成员
发帖
与我相关
我的任务
分享Dim KeyAscii As Short = Asc(e.KeyChar)
If KeyAscii = 13 Then
SendKeys.Send("{TAB}")
End If
If In_Int(KeyAscii) = False Then
KeyAscii = 0
End If
e.KeyChar = Chr(KeyAscii)
If KeyAscii = 0 Then
e.Handled = True
End If
' 只接受数字输入
Private Function In_Int(ByRef KeyAscii As Short) As Boolean
Dim i As Integer
Dim Ch_Accept_Int(20) As String ' 可以接受字符数组
Ch_Accept_Int(0) = "0"
Ch_Accept_Int(1) = "1"
Ch_Accept_Int(2) = "2"
Ch_Accept_Int(3) = "3"
Ch_Accept_Int(4) = "4"
Ch_Accept_Int(5) = "5"
Ch_Accept_Int(6) = "6"
Ch_Accept_Int(7) = "7"
Ch_Accept_Int(8) = "8"
Ch_Accept_Int(9) = "9"
Ch_Accept_Int(10) = Chr(8)
' 检查输入的字符是否在数组中
In_Int = False
For i = 0 To 10
If Chr(KeyAscii) = Ch_Accept_Int(i) Then
In_Int = True
End If
Next
End Function