How to pass data in Array to Message Box

G

Guest

How Can I loop through the array, gradually buildin
up delimited list by concatenating each used element in turn to
string variable

If you want to know more details why do I ask above see below.

Thanks,
Sena

Senad said:
I have data in array strRecTo (14) whre data is collected usin
several IF....Then...Els
I would like to pass this data to Message Box, just I do not know how
the simple code looks like
Dim Counter as Intege
Counter =
While Counter <=1
If (condition) the
strRecTo (0, 1) = "something 1
Els
Counter = Counter +


If (condition) the
strRecTo (13) = "something 13
Els
Counter = Counter +
Wen
MsgBox ("Message needs to be send to: AND NOW i WOULD LIKE TO HAV
DISPLAYED MY ARRAY SEPARATED WITH COMAS OR COLUMN) Thanks in Advanc
Sena

Try something like this

MsgBox "Message needs to be sent to: " & Join(strRecTo, ", "

If you have empty entries at the end of the array, though, you may en
up with trailing commas; e.g.

Message needs to be sent to: this, that, the other, , ,

To avoid that, I think you'd need to use a dynamic array and use Redi
Preserve after filling it, to give it the exact number of elements tha
you are actually using. If that's too much trouble, you could of cours
forget using Join() and just loop through the array, gradually buildin
up your delimited list by concatenating each used element in turn to
string variable
 
G

Guest

For i = 0 To UBound(aray)
str = aray(i) & ";" & str
Next
MsgBox str

Edmund
MCP - Access & SQL Server
----- Senad wrote: -----

How Can I loop through the array, gradually building
up delimited list by concatenating each used element in turn to a
string variable.

If you want to know more details why do I ask above see below.

Thanks,
Senad


Senad said:
I have data in array strRecTo (14) whre data is collected using
several IF....Then...Else
I would like to pass this data to Message Box, just I do not know how.
the simple code looks like:
Dim Counter as Integer
Counter = 0
While Counter <=14
If (condition) then
strRecTo (0, 1) = "something 1"
Else
Counter = Counter +1
.
.
If (condition) then
strRecTo (13) = "something 13"
Else
Counter = Counter +1
Wend
MsgBox ("Message needs to be send to: AND NOW i WOULD LIKE TO HAVE
DISPLAYED MY ARRAY SEPARATED WITH COMAS OR COLUMN) Thanks in Advance
Senad

Try something like this:

MsgBox "Message needs to be sent to: " & Join(strRecTo, ", ")

If you have empty entries at the end of the array, though, you may end
up with trailing commas; e.g.,

Message needs to be sent to: this, that, the other, , , ,

To avoid that, I think you'd need to use a dynamic array and use Redim
Preserve after filling it, to give it the exact number of elements that
you are actually using. If that's too much trouble, you could of course
forget using Join() and just loop through the array, gradually building
up your delimited list by concatenating each used element in turn to a
string variable.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top