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!

identifying records by character structure 1

Status
Not open for further replies.

horsecarriage

Programmer
Apr 21, 2005
3
US
while moving through a recordset I need to be able to identify records that have the following format:

6535-5

in other words

digit digit digit dash digit

The record comes from an access database with the field datatype set to text.

One thing to keep in mind is that the record can be of the following format:

6535-5?A

but it doesn't have to be. Some records go beyond the first 6 characters, but I am not interested in what comes after, I just need to make sure the script recognizes records that are longer than 6 characters as well.

I need to do this with asp and vb

thanks for your help

 
There is probably a more efficient way but one quick and dirty would be:
Code:
bIsOK = False
If (Mid(MyString,5,1) = "-") Then
  If IsNumeric(Left(MyString,4)) Then
    If IsNumeric(Mid(Mystring,6,1)) Then
      bIsOk = True
    End If
  End If
End If
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top