I am trying to develop a programe in Visual basic.ne(.NET Framework 3.5) where textbox will only accept integer. User wont be able to type char/decimel or other type.
Can anyone please help me?
Thanks in advance.
I am trying to develop a programe in Visual basic.ne(.NET Framework 3.5) where textbox will only accept integer. User wont be able to type char/decimel or other type.
Can anyone please help me?
Thanks in advance.
Here's an article describing just the control you need (including not allowing decimals):
The article's code is C#, but as the author notes the control is packaged in a DLL you can use in a VB.NET project.
Just handle the keypress event and test the keychar to make sure it is numeric.
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
If Not IsNumeric(e.KeyChar) Then
e.Handled = True
End If
End Sub