I don't want allow user to insert the string value in the textbox. How I can do that?
Printable View
I don't want allow user to insert the string value in the textbox. How I can do that?
vb Code:
Private Sub Text1_KeyPress(KeyAscii As Integer) If (KeyAscii < 48 Or KeyAscii > 57) And KeyAscii <> 46 And KeyAscii <> 13 Then MsgBox "Only numbers are allowed for this entries" KeyAscii = 0 Exit Sub End If End Sub 'also, in the change event put this code 'to prevent pasting in non numeric text Private Sub Text1_Change() If Not IsNumeric(Text1.Text) Then MsgBox "Only Numbers Are Allowed" Text1.Text = vbNullString Exit Sub End If End Sub