General Question

jlm11f's avatar

Question about the Split Function in Visual Basic?

Asked by jlm11f (12416points) November 7th, 2008

Ok. bear with me, I am exhausted. I am entering a full name in a text box (so first + middle + last) and want the info in that text box to be divided using the Split Function with delimiter ” ” (or basically a space). How do I get each new array assigned to a different variable?

Observing members: 0 Composing members: 0

6 Answers

Snoopy's avatar

quit lurking and write something to help her for heaven’s sake! the girl is desperate and the clock is ticking

jasongarrett's avatar

I don’t think you want to assign each array element to a different variable, but if you do, it would be something like:

Dim fullname As String = “P n L”
Dim nameArray As String = Split(fullname)
Dim firstName As String = nameArray[0]
Dim middleName As String = nameArray[1]
Dim lastName As String = nameArray[2]

I don’t know VB, so don’t trust my syntax. My answer is based on this page: http://msdn.microsoft.com/en-us/library/6×627e5f(VS.80).aspx.

jlm11f's avatar

@jason – YES. That’s exactly what I wanted. Thank you so much!!!

PS – your link doesn’t work, but that’s okay

jasongarrett's avatar

Microsoft didn’t make a friendly URL… it’s currently the first result for vb split function.

jlm11f's avatar

see, i did read that page. but somehow i didn’t get the “0” “1” “2” thing out of it. And I also didn’t realize I had to Dim namearray As Array (if you Dim it As String, it doesn’t work)

jasongarrett's avatar

Whoops, yeah, looks like my second line should have been:
Dim nameArray() as String = Split(fullname)

Answer this question

Login

or

Join

to answer.

This question is in the General Section. Responses must be helpful and on-topic.

Your answer will be saved while you login or join.

Have a question? Ask Fluther!

What do you know more about?
or
Knowledge Networking @ Fluther