[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Join the vaules of a text box together.

Posted on 2004-11-14
8
Medium Priority
?
231 Views
Last Modified: 2010-05-02
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
0
Comment
Question by:Spankz
8 Comments
 
LVL 33

Expert Comment

by:hongjun
ID: 12578537
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
 
LVL 11

Expert Comment

by:dbrckovi
ID: 12578650
To join 2 or more strings just use     &   operator.

Text3.Text = Text1.Text & Text2.Text
0
 
LVL 32

Expert Comment

by:Erick37
ID: 12578705
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Spankz
ID: 12578835
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
 
LVL 33

Accepted Solution

by:
hongjun earned 260 total points
ID: 12578855
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
 

Expert Comment

by:StephenJnr
ID: 12578962
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
 
LVL 33

Expert Comment

by:hongjun
ID: 12578964
it will not add since str is empty
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month20 days, 8 hours left to enroll

868 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question