给你我私藏的函数 'KeyAscii = ValiText(KeyAscii, "0123456789/-", True) 调用方法 '只接受第二个参数提供的字符 '即:"0123456789/-", 而此函数的第三个函数就决定了能否使用 [Backspace] 键。 '此函数对大小写是不敏感的Function ValiText(KeyIn As Integer, ValidateString As String, Editable As Boolean) As Integer Dim ValidateList As String Dim KeyOut As Integer If Editable = True Then ValidateList = UCase(ValidateString) & Chr(8) Else ValidateList = UCase(ValidateString) End If If InStr(1, ValidateList, UCase(Chr(KeyIn)), 1) > 0 Then KeyOut = KeyIn Else KeyOut = 0 Beep End If ValiText = KeyOut End Function
'KeyAscii = ValiText(KeyAscii, "0123456789/-", True) 调用方法
'只接受第二个参数提供的字符
'即:"0123456789/-", 而此函数的第三个函数就决定了能否使用 [Backspace] 键。
'此函数对大小写是不敏感的Function ValiText(KeyIn As Integer, ValidateString As String, Editable As Boolean) As Integer
Dim ValidateList As String
Dim KeyOut As Integer
If Editable = True Then
ValidateList = UCase(ValidateString) & Chr(8)
Else
ValidateList = UCase(ValidateString)
End If
If InStr(1, ValidateList, UCase(Chr(KeyIn)), 1) > 0 Then
KeyOut = KeyIn
Else
KeyOut = 0
Beep
End If
ValiText = KeyOut
End Function