Private Sub Text1_KeyPress(KeyAscii As Integer) If KeyAscii > 57 Or KeyAscii < 48 Then KeyAscii = 0 End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer) If KeyAscii <> 8 Then If (KeyAscii >= 48 And KeyAscii <= 58) Or KeyAscii = 46 Then Else KeyAscii = 0 End If End If End Sub8是退格键,46是小数点
If KeyAscii > 57 Or KeyAscii < 48 Then KeyAscii = 0
End Sub
If KeyAscii <> 8 Then
If (KeyAscii >= 48 And KeyAscii <= 58) Or KeyAscii = 46 Then
Else
KeyAscii = 0
End If
End If
End Sub8是退格键,46是小数点
最简单的是用VB的MaskEdit控件。