Private Sub TextBox1_KeyPress(ByVal sender As Object,ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress,TextBox2.KeyPress,TextBox3.KeyPress '判断输入的是否是数字、小数点或“BackSpace”符号 If Char.IsDigit(e.KeyChar) Or e.KeyChar = "." Or e.KeyChar = Chr(8) Then '判断输入的小数点是否唯一 If e.KeyChar = "." And InStr(CType(sender,TextBox).Text,".") > 0 Then e.Handled = True Else e.Handled = False End If '判断输入的负号是否是在第一位 ElseIf e.KeyChar = "-" And CType(sender,TextBox).Text = "" Then e.Handled = False Else e.Handled = True End If End Sub