Re: only numbers in textbox
Posted 15 October 2008 - 06:03 PM
You were supposed to put that code in a KeyDown event, not a TextChanged Event. Create a KeyDown event for your text box, and put that same code in it. Like this:
1 | Private Sub TextBox1_KeyDown( ByVal sender As Object , ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown |
2 | If Asc(e.KeyChar) <> 13 AndAlso Asc(e.KeyChar) <> 8 _ |
3 | AndAlso Not IsNumeric(e.KeyChar) Then |
4 | MessageBox.Show( "Only Numbers" ) |
5 | e.Handled = True |
6 | End If |
7 | End Sub |
Same problem.
Tidak ada komentar:
Posting Komentar