0

Hey

I want to control a textbox to only allow numbers, backspace and a certain length. Ive tried with the IsNumeric function but I cant seem to get it to work.

Thanks.

6
Contributors
5
Replies
44
Views
5 Years
Discussion Span
Last Post by princenathan
Featured Replies
  • check this .. its just wat you want: [URL="http://winform-net.blogspot.com/2011/05/numeric-only-textbox.html"]http://winform-net.blogspot.com/2011/05/numeric-only-textbox.html[/URL] Read More

  • Hi, To create a numeric textbox, look [URL="http://msdn.microsoft.com/en-us/library/ms229644(v=vs.80).aspx"]here.[/URL] To select a certain length, go to the properties of that textbox and set the Maxlength. Read More

  • Just put this code in your keypress event in your textbox [CODE]Select Case e.KeyChar Case "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", vbBack e.Handled = False Case Else e.Handled = True End Select[/CODE] if you want to change the input length of textbox just click the properties … Read More

1

Hi,

To create a numeric textbox, look here.

To select a certain length, go to the properties of that textbox and set the Maxlength.

Comments
agree
1

Just put this code in your keypress event in your textbox

Select Case e.KeyChar
            Case "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", vbBack
                e.Handled = False
            Case Else
                e.Handled = True
        End Select

if you want to change the input length of textbox just click the properties and then change the MaxLength Value.

0

Just put this code in your keypress event in your textbox

Select Case e.KeyChar
            Case "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", vbBack
                e.Handled = False
            Case Else
                e.Handled = True
        End Select

if you want to change the input length of textbox just click the properties and then change the MaxLength Value.

Nice solution!
Thanks so much! :)

0
If Textbox1.Text = "" Then
            GoTo ex

        Else
            If IsNumeric(Textbox1.Text) Then
                GoTo ex
            Else
                MsgBox("You cannot add alpha characters, please input the Integer or numbers !", vbCritical)
                Textbox1.Text = ""
                searchback()
            End If
        End If
ex:
        Exit Sub

Edited by Ezzaral: Added code tags.

This question has already been answered. Start a new discussion instead.
Be sure to adhere to our posting rules.