Text Box using instr, mid, left function

I have 4 text boxes
Text1.Text = Joe Sam Doe
I need the other 3 text boxes to show 1 word per text box LIKE:

Text2.Text = Joe
text3.text = Sam
text4.text = Doe

I guessing mid or instr function might work but I'm not sure how to do it.
If their is a better or faster way to do it, please post it.

I am using Visual Basic 6 pro.

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jorge PaulinoIT Pro/DeveloperCommented:
Hi daneburr,

Try this way:

Dim str() As String

str = Split(Text1.Text, " ")
Text2.Text = str(0)
Text3.Text = str(1)
Text4.Text = str(2)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
or if you want to use left/mid

Dim a As Integer, b As Integer

'//This will find the location of the first space in Text1 (the one after Joe)
'  and add 1 to get it past the space.
a = InStr(1, Text1.Text, " ") + 1

'//This will find the location of the second space in Text1 (the one after Sam)
b = InStr(a, Text1.Text, " ")

'//This will take all the characters before the first space, leaving only Joe in Text2
Text2.Text = Left(Text1.Text, a - 2)

'//This will take all the characters between the two spaces, leaving just Sam in Text3
Text3.Text = Mid(Text1.Text, a, b - a)

'//This will get all the characters after the second space, leaving just Doe in Text4
Text4.Text = Mid(Text1.Text, b + 1)
Jorge PaulinoIT Pro/DeveloperCommented:
Thanks for the grade.

You can use this for validations UBound(str). This displays the size of the array.Don't forget that the arrays are zero based.

If you need to check the values of your array you can do this:
Dim x As Integer
For x = 0 to UBound(str) -1
  Msgbox str(x)
Next x
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.