the_one2003a
Member
- Joined
- May 15, 2005
- Messages
- 10
- Programming Experience
- Beginner
I wanted to make a text box that only accepts numbers and doesn't allow zeroes to be entered in first of the user input (for example doesn't allow: 0009).
Below is my code:
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
If Not (e.KeyChar >= "0" And e.KeyChar <= "9" Or e.KeyChar = ".") Then
e.Handled = True
Else
TextBox1.Text = TextBox1.Text().TrimStart("0")
End If
End Sub
This code works very well but when I enter "123" in the text box and then press home and "0", Zero (0) is show in the text one time L
How can I avoid the zero to be showed at first of this text box?
Thanks