shilpi2
asked on
Splitting when space
Hi Experts,
I have an array and I am looping the array. Each row of the array will have an entry like A B .I want to split the record when I come across the first space and store it in another variable. How do I achieve it. I am unable to do this with split function.
Thanks
Shilpi
I have an array and I am looping the array. Each row of the array will have an entry like A B .I want to split the record when I come across the first space and store it in another variable. How do I achieve it. I am unable to do this with split function.
Thanks
Shilpi
Dim m As Long
m = 0
Do Until IsEmpty(varArray3)
Dim Portfolio As String
Portfolio = Split(varArray3(m), " ")(0)
Loop
Is this VB.NET or VBScript?
ASKER
I get subscript out of range error. The space just spearates 2 words. There is no limit to the length of a word.
Thanks
Thanks
If it isn't a hard space then what is it ...
when it 'breaks on the error, type the string into the immediate window ... ctrl + G to display it
Now find where you think the space is in the word and type into the immediate window:
?asc(mid(varArray3(m), 5))
replace 5 with the character position of the space ... what do you get?
Chris
when it 'breaks on the error, type the string into the immediate window ... ctrl + G to display it
Now find where you think the space is in the word and type into the immediate window:
?asc(mid(varArray3(m), 5))
replace 5 with the character position of the space ... what do you get?
Chris
?varArray3(m)
will display the actual string
Chris
will display the actual string
Chris
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
> I get subscript out of range error.
That can happen because varArray3(0) is out of range (or the array isn't dimensioned), or because varArray3(m) is an empty string. Split("") returns an array with -1 as upper bound.
(°v°)
That can happen because varArray3(0) is out of range (or the array isn't dimensioned), or because varArray3(m) is an empty string. Split("") returns an array with -1 as upper bound.
(°v°)
Portfolio = Split(replace(varArray3(m)
Chris