Private Sub Form_Load()
gNumbers = "1234567890" + Chr(8) + Chr(45) + Chr(46) '控制TextBox框只能输入数字的字符串
End Sub
Private Sub TxtSL_KeyPress(KeyAscii As Integer)
If InStr(gNumbers, Chr(KeyAscii)) = 0 Then KeyAscii = 0
If KeyAscii = 46 And InStr(TxtSL.Text, ".") <> 0 Then KeyAscii = 0 '"."点号只能出现一次
If KeyAscii = 45 Then '"-"号必须放在第一位,且只能出现一次
If InStr(TxtSL.Text, "-") <> 0 Then
KeyAscii = 0
Else
TxtSL.SelStart = 0
End If
End If
End Sub