Private Sub Form_Load()
decimaltag = False
End Sub
Private Sub Text1_Change()
If InStr(1, Trim$(Text1.Text), ".") Then
decimaltag = True
End If
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 46 And decimaltag = False Then
decimaltag = True '控制小数点只能输入一次。
ElseIf KeyAscii >= vbKey0 And KeyAscii <= vbKey9 Then
Exit Sub
ElseIf KeyAscii <= 31 Then
Exit Sub '控制可接受退格键或删除键等。
Else
KeyAscii = 0
End If
End Sub