|
-
Nov 2nd, 2005, 07:45 AM
#1
Thread Starter
Fanatic Member
string validation
I would like to make sure the entered value in a text box on the windows form is as follows:
1)it must be seven characters long
2) it must comprise of the first character being a letter
3)and the following six characters being numerical digits.
Thanks
-
Nov 2nd, 2005, 08:26 AM
#2
Frenzied Member
Re: string validation
have you looked at using regular expressions. You could also use a validation control to assist this. See what you can find Im sure its the way to go.
-
Nov 2nd, 2005, 08:33 AM
#3
Frenzied Member
Re: string validation
Something like this?
Is a reg ex
-
Nov 2nd, 2005, 09:23 AM
#4
Frenzied Member
Re: string validation
Look although the reg ex doesnt work how it should this demonstrates me using the imports system.text.regularexpressions namespace then employing it in the validating event of my textbox control.
From here its just a case of getting the right regex.
VB Code:
Private Sub txtCallNotes_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles txtCallNotes.Validating
Dim expr As New Regex("\d{6}")
If expr.ismatch(Me.txtCallNotes.Text) Then
MessageBox.Show("OK")
Else
MessageBox.Show("Bad")
End If
End Sub
-
Nov 2nd, 2005, 09:24 AM
#5
Re: string validation
Use the Regex.IsMatch() function with FishGuy's regex string to compare the inputs.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|