Parsing data

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a string that is like:

"Self-Assessment 3 which covers: MFG14, MFG15"

or

"Self-Assessment 5 which covers: MFG19"

I am trying to figure out how to pull out the course #s (to the right of the
colon). Some only have one as part of the text and some have 2 or more,
always separated by commas.

Any suggestions?

Thanks,
Clint
 
You need two steps: the first is to find the colon:

intPos = instr(StringVariable,":")
StringVariable = trim(mid(stringVariable,intpos+1))

Now you have:

MFG14, MFG15

Next, use the Split function to put the different options in an array:

Dim strWords() as string
StrWords = split(StringVariable,",")

dim intCounter as Integer
for intcounter = lbound(strwords) to ubound(strwords)
Debug.print strwords(intcounter)
next intcounter




Chris Nebinger
 
Thanks. Perfect!

You need two steps: the first is to find the colon:

intPos = instr(StringVariable,":")
StringVariable = trim(mid(stringVariable,intpos+1))

Now you have:

MFG14, MFG15

Next, use the Split function to put the different options in an array:

Dim strWords() as string
StrWords = split(StringVariable,",")

dim intCounter as Integer
for intcounter = lbound(strwords) to ubound(strwords)
Debug.print strwords(intcounter)
next intcounter




Chris Nebinger
 
Back
Top