How to split up this string (1 Viewer)

davesmith202

Employee of Access World
Local time
Today, 21:02
Joined
Jul 20, 2001
Messages
522
I have a string:

Cars > Car Import > Car Import: Car Import

The first section is the Category, the second is the Product, the third is the SubProduct and the fourth is the keyword.

What is the best way to split each of these words into its own variable? I think I can do the first and end one but not the Car Import and Car Import one.

Thanks,

Dave
 

Mile-O

Back once again...
Local time
Today, 21:02
Joined
Dec 10, 2002
Messages
11,316
Use the Split() function.
 

davesmith202

Employee of Access World
Local time
Today, 21:02
Joined
Jul 20, 2001
Messages
522
So would I do something like this?

myArray(x)=split(myString,">") or something?

I can't find an example in Access help.
 

Mile-O

Back once again...
Local time
Today, 21:02
Joined
Dec 10, 2002
Messages
11,316
Code:
Const TestString As String = "Cars > Car Import > Car Import: Car Import"

Dim strText As String
Dim strParts() As String
Dim intCounter As Integer

strText = Replace(TestString, ":", " >")
strText = Replace(strText, " > ", ">")

strParts = Split(strText, ">")

For intCounter = LBound(strParts()) To UBound(strParts())
    MsgBox strParts(intCounter)
Next intCounter
 

Users who are viewing this thread

Top Bottom