schwientekd
asked on
First occurence in For Each statement
I've got a For Each statement written in visual studio using vb. It takes a comma separated statement and runs something on each item separated by the commas. I need to do something special with the first item. How could I do this?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Worked perfect. Thanks for the quick response.
dim commastring as String = "thingone, thingtwo, thingthre, blaj"
dim StrArr() as String
StrArr = Split(commstring,",") <---this creates a String Array using the comma in your original string to as a separator
Now, you can do whatever you'd like to the first thing by refering to it directly - outside of the context of a loop.
StrArr(0) (which in the example I've shown here would be equal to "thingone"
And to loop through your string array you could do:
dim i as Integer = 0
for i = 0 to ubound(StrArr)
next