Private Sub Text1_KeyPress(KeyAscii As Integer) Select Case KeyAscii Case Asc("0") To Asc("9"), vbKeyBack '允许0~9数字和退格键
Case Asc(".") '允许一个小数点 If InStr(1, Text1.Text, ".") > 0 Then KeyAscii = 0 Case Else KeyAscii = 0 Beep '其他的发出Beep声音 End Select End Sub