954,517 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

about textbox

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 :)

nore
Light Poster
38 posts since Sep 2010
Reputation Points: 10
Solved Threads: 5
 

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

__avd
Posting Genius (adatapost)
Moderator
8,648 posts since Oct 2008
Reputation Points: 2,136
Solved Threads: 1,241
 
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.

codeorder
Posting Virtuoso
1,913 posts since Aug 2010
Reputation Points: 255
Solved Threads: 384
 

codeorder thank you very much, its work :D

nore
Light Poster
38 posts since Sep 2010
Reputation Points: 10
Solved Threads: 5
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: