VB.net splitline

Soldato
Joined
12 Jan 2006
Posts
2,547
Hi all,
Just a quick question
I have the string "this is_stuff" and i want to split the line to get the result
a = this
b = is
c = stuff

I did the following:
Code:
' Holds results from split
dim result(2) as string
dim result2(2) as string

dim strline as string = "this is_stuff"

        result = strline.Split(" ")    'Split based on space character
        result2 = result(1).Split("_") 'Split second half of string based on _

        MessageBox.Show("a=" + result(0) + "b=" + result2(0) + "c=" + result2(1))

While this works, i am wondering if there is a better way to do this?
 
Code:
strline.Split(New Char() { "  "c, "_"c })

I think.

EDIT: The equivalent in C# which works is:
Code:
strline.Split(new [] {' ', '_'});
 
Last edited:
Back
Top Bottom