Software Engineer, Equity Strategist, Polymath.
Make a Textbox that accepts only numbers
[codesyntax lang=”vbnet” highlight_lines=””]
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
Const pstr As String = “0123456789”
If pstr.IndexOf(e.KeyChar) = -1 Then
e.Handled = True
End If
End Sub
[/codesyntax]
If you want to add “.” for exmaple to the combination you can change first line to [codesyntax lang=”vbnet” highlight_lines=””]
Const pstr As String = "0123456789"
[/codesyntax]
Comments are closed.