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 (,)?
Printable View
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 (,)?
IF you have vb6:
dim sMsg as string
sMsg = Join(myArray, ",")
msgBox sMsg
Charlie Zimmerman
http://www.freevbcode.com
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