Hello all, i want to know some textbox case.
I want to make my textbox (example textbox1) only can be written by numeral, if there was non numeral input, textbox1 not allow or just being ignored.
Thanks for attention or help :)

Recommended Answers

All 3 Replies

You can do this by handle "KeyPress" event. For further reference read MSDN pages.

Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
        Select Case e.KeyChar
            Case "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", vbBack '// numeric and backspace.
                Exit Sub
            Case Else
                e.Handled = True
        End Select
    End Sub

Should work.
Using shortcut keys to Cut, Copy, Paste does not.

commented: Good and easy +1

codeorder thank you very much, its work :D

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.