hi all
i am trying to stop people from entering anything but numbers into a textbox.
i have the code to make sure they have entered a number on each keypress event and now a msgbox appears if they enter a non numeric value but how do i stop the character from appearing in the textbox.
here is my code
thanks eirc
i am trying to stop people from entering anything but numbers into a textbox.
i have the code to make sure they have entered a number on each keypress event and now a msgbox appears if they enter a non numeric value but how do i stop the character from appearing in the textbox.
here is my code
Code:
Private Sub txtA_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtA.KeyPress, txtB.KeyPress, txtC.KeyPress Dim key As Char Dim intkey As Integer key = e.KeyChar intkey = Asc(key) If (intkey >= 48 And intkey <= 57 Or intkey = 8 Or intkey = 9 Or intkey = 13) Then Exit Sub Else 'here i would like somthing that stops the non numeric value from appearing in the textbox MsgBox("only numbers please") End If End Sub
Comment