# 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.

Thanks
###### 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.

IT 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)
0

Experts Exchange Solution brought to you by

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

Commented:
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)
0
IT Pro/DeveloperCommented: