Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Formating data input

Status
Not open for further replies.

darksirius

Technical User
Nov 26, 2005
18
MY
Hi everyone..

I need help how to accept data in certain input, for example if user input string it will give error msg ( i already got that ), but I need to set it to only accept 6 integer only, not more than that, really hope someone can help figure this out. Cheers
 
There are several tricks to do that. Here's one of them:
Code:
If IsNumeric(TextBox1.Text) Then
   If TextBox1.Text.Trim.Length = 6 Then
      Messagebox.Show("Valid")
   Else
      Messagebox.Show("Numeric but not long enough")
   End If
Else
   Messagebox.Show("Not a 6 digit numeric input.")
End If

Regards,
mansii
 
I got it, i tried like this

If cboDocType.Text = "New IC Num" Then
If txtDocNo.Text.Length <> 14 Then
MessageBox.Show("Please input valid new I.C. number", "Testing", MessageBoxButtons.OK, MessageBoxIcon.Information)
Else
..........

it works fine wif me, but I just wondering if I could combine both the character length and to check the data whether is it numeric or not, should I use or for that purpose. Thanx
 
the textbox also has a maxlength propertie. So you could use that just set it to 6 or whatever you need.

Christiaan Baes
Belgium

"My new site" - Me
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top