Click to See Complete Forum and Search --> : Integer Array in a Message Box


November 17th, 1999, 04:24 PM
I have an integer variable array with values that I want displayed in a message box. How do I show each value of the array in a message box, seperated by a comma (,)?

czimmerman
November 17th, 1999, 04:28 PM
IF you have vb6:

dim sMsg as string
sMsg = Join(myArray, ",")
msgBox sMsg

Charlie Zimmerman
http://www.freevbcode.com

Chris Eastwood
November 17th, 1999, 04:30 PM
Try something like :


Dim iArr() as Integer
Dim iCount as Integer
Dim sOut as string
'
' Populate the array - random length, random values
'
ReDim iArr(Rnd(1) * 10)

for iCount = 0 to UBound(iArr)
iArr(iCount) = Rnd(1) * 10
next
'
' Show the array in a string
'
for iCount = 0 to UBound(iArr)
sOut = sOut & CStr(iArr(iCount)) & ","
next
'
' Remove last comma
'
sOut = Left$(sOut, len(sOut) - 1)
'
' Show It !
'
MsgBox "Array is : " & sOut






Chris Eastwood

CodeGuru - the website for developers
http://codeguru.developer.com/vb