Parse string with various char and type

G

Guest

I have a field in my database (comes from another source) that has a string
with various character types and lengths. It is always has a few numeric
values followed by 3 text characters followed by 3a few numeric values. For
example 60738POL237497 or 16MHH19108.

I need to separate the numeric values after the text from the string. Is
there any way to split this into the three portions or to replace the text
with a delimiter that can be used for parsing?
 
P

Peter Gonzales

Frank,

This piece of code may help.

PartPos = 0
For X = 1 To Len(str)
sChar = Mid(str, X, 1)
Select Case UCase(sChar)
Case "0" To "9"
If PartPos <= 1 Then
PartPos = 1
Part1 = Part1 & sChar
Else
PartPos = 3
Part3 = Part3 & sChar
End
Case "A" To "B"
PartPos = 2
Part2 = Part2 & sChar
End Select
Next

Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top