How to pass data in Array to Message Box

S

Senad

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 strRecTo (1) as Strin
Dim Counter as Intege
Counter =
While Counter <=1
If (condition) the
strRecTo (0, 1) = "something 1
Els
Counter = Counter +
 
D

Dirk Goldgar

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 strRecTo (1) as String
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

Dirk Goldgar sugested to use Join() function.

Could someone give me an example.

Thanks

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