SPLIT string error

chris-uk-lad

Registered User.
Local time
Today, 07:31
Joined
Jul 8, 2008
Messages
271
hi all,

Just kinda bumping this cause its annoying me XD

Code:
dim strArray() as variant
dim strName as string

strName = "123-1-Cornwall"

strArray = split(strName, "-")

strname = strAray(1) & " - "  & strArray(3)

Problem being it says type mismatch on the line:
strArray = split(strName, "-")
The syntax for splitting the string whereever "-" occurs looks correct to me so not sure why its popping this error. Any thoughts?
 
If you want to bump a thread use the same thread and add a request.

This code seems to do the job when I tested it.
Code:
Dim strArray() As String
Dim strName As String
strName = "123-1-Cornwall"
strArray = Split(strName, "-")
strName = strArray(0) & " - " & strArray(2)
 
hi all,

Just kinda bumping this cause its annoying me XD

Code:
dim strArray() as variant
dim strName as string

strName = "123-1-Cornwall"

strArray = split(strName, "-")

strname = strAray(1) & " - "  & strArray(3)

Problem being it says type mismatch on the line:
strArray = split(strName, "-")
The syntax for splitting the string whereever "-" occurs looks correct to me so not sure why its popping this error. Any thoughts?
You have spelt strArray as strAray in the last line.

Regards
Chris
 
As Rabbie pointed out, the array is zero based so will only have elements 0,1,2 and not 3.
Chris
 

Users who are viewing this thread

Back
Top Bottom