Private Sub Text1_KeyPress(KeyAscii As Integer)
Select Case Trim(Text1)
Case "+", "-"
If InStr("0123456789", Chr(KeyAscii)) > 0 Then
Else
If Strings.InStr("3,13,8,24,26", KeyAscii) = 0 Then KeyAscii = 0
End If
Case "+0", "-0"
If KeyAscii = 46 Then
Else
If Strings.InStr("3,13,8,24,26", KeyAscii) = 0 Then KeyAscii = 0
End If
Case Else
If InStr(Trim(Text1), Chr(46)) > 0 Then
If InStr("0123456789", Chr(KeyAscii)) > 0 Then
Else
If Strings.InStr("3,13,8,24,26", KeyAscii) = 0 Then KeyAscii = 0
End If
Else
If InStr("0123456789.", Chr(KeyAscii)) > 0 Then
Else
If Strings.InStr("3,13,8,24,26", KeyAscii) = 0 Then KeyAscii = 0
End If
End If
End Select
End Sub
其中 3是复制 13是回车 8是backspace24是剪切 26是撤消