CoachBarker
Well-known member
- Joined
- Jul 26, 2007
- Messages
- 133
- Programming Experience
- 1-3
I have a text box that I would like to validate the format entered.
To valiate the format of a Full Name as LastName, FirstName [MI] i do this using indexOf to check that the format is correct
I want to validate the format of this: Dr. FirstName LastName
I know I have to use indexOF and substrings but can't figure it out. This is what I have. I just just do not know how to figure the spaces for the First and Last Name.
Any help?
Thanks
CoachBarker
To valiate the format of a Full Name as LastName, FirstName [MI] i do this using indexOf to check that the format is correct
VB.NET:
' Check PatientFullName
If Me.txtPatientFullName.Text = "" Or Me.txtPatientFullName.Text.IndexOf(",") < 0 Then
MessageBox.Show("The Doctors Name is mandatory and must be in the
format: LastName, FirstName [MI]")
Me.txtPatientFullName.Clear()
Me.txtPatientFullName.Focus()
Exit Sub
End If
I want to validate the format of this: Dr. FirstName LastName
I know I have to use indexOF and substrings but can't figure it out. This is what I have. I just just do not know how to figure the spaces for the First and Last Name.
VB.NET:
' Check Doctors Name
If Me.txtDoctorName.Text = "" Or Me.txtDoctorName.Text.StartsWith("Dr. ") Then
MessageBox.Show("The Patient Name is mandatory and must be in the
format: Dr. FirstName LastName")
Me.txtDoctorName.Clear()
Me.txtDoctorName.Focus()
Exit Sub
End If
Any help?
Thanks
CoachBarker