Why my split function doesn't work

J

joyo

I don't know why my split function doesn't work. See the code below.

Dim str As String
Dim substr As String
Dim mArray() As String
Dim mArrayUpper As Integer
Dim mCounter As Integer

str = "This\is\a\test"
mArray = Split(str, "\") 'this line got error message
mArrayUpper = UBound(mArray)
For mCounter = 0 To mArrayUpper
substr = mArray(mCounter)
Next mCounter

I just got the error message, "Run-time error 13, Type mismatch"

Why?

Thanks

joyo
 
A

Art

Hi Joyo,
I ran your code and recieved no error. Try running
the code in a new Sub or Function and see if it works. If
so, then the mismatch is coming from some field or
variable in the original environment:)

The Easy Day
 

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