Join the vaules of a text box together.

Hi there, is there a way of joining the values of text boxes together ? But not limited to just two text boxes, could be up to 20 say. ie

Text(0).text = boat
Text(1).text = fish
Text(2).text = cat
....
Text(20).text = bike

TextJoined.text  = boat, fish, cat ...., bike

?
Thanks
SpankzAsked:
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.

hongjunCommented:
try this


Dim i as integer
Dim str as String

str = ""
For i = 0 to 20
    str = str & Text(i).text & ", "
Next

str = Left(str, Len(str)-2)
TextJoined.text = str
0
dbrckoviCommented:
To join 2 or more strings just use     &   operator.

Text3.Text = Text1.Text & Text2.Text
0
Erick37Commented:
Since you are using a control array you can use the Lbound and Ubound properties in the loop.

Dim i as long

For i = Text.LBound to Text.Ubound

    TextJoined.Text = TextJoined.Text & Text(i).Text & IIf(i = Text.Ubound, "", ",")

Next
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

SpankzAuthor Commented:
Is there any way of being able to add the boxes together depending upon if a box has changed value, sorry i was no were near specific when I asked the question,

Say

If text1.text = rs.fields("Text1") then  <<<< Same
next
else
add to text box

If text2.text = rs.fields("Text2") then <<<< Not The same
next
else
add to text box

If text3.text = rs.fields("Text3") then <<<< Same
next
else
add to text box


Output.text = text1.text & text3.text

and if it is not the same it will add it.

I know this is kind of a different question, i will give a link for an extra 100 points.
0
hongjunCommented:
str = ""

If text0.text <> rs.fields("Text0") then
      str = str & text0.text & ", "
end if

If text1.text <> rs.fields("Text1") then
      str = str & text1.text & ", "
end if

If text2.text <> rs.fields("Text2") then
      str = str & text2.text & ", "
end if
...

If text20.text <> rs.fields("Text20") then
      str = str & text20.text & ", "
end if

if str <> "" then
      str = Left(str, Len(str)-2)
end if
TextJoined.text = str
0

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
StephenJnrCommented:
Thanks works great, but how would i skip adding it to the finial text box if it has not been changed ?, at the moment it will add every text box

Thanks
0
hongjunCommented:
it will not add since str is empty
0
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.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.