Pages

Total Pageviews

Add This

Sunday, May 8, 2011

Just numbers in TextBox

If you want your TextBox to allow just numbers enter the code bellow:    


Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox2.KeyPress
        If Asc(e.KeyChar) <> 13 AndAlso Asc(e.KeyChar) <> 8 AndAlso Not IsNumeric(e.KeyChar) Then
            MessageBox.Show("Only numbers allowed")
            e.Handled = True
        End If
    End Sub

No comments:

Post a Comment