PDA

View Full Version : Solved: Manipulation on Array elements



arrun
11-20-2012, 05:17 AM
Dear all, I have an array of strings, like:


dim StringArray(5) as string
StringArray(1) = "a"
StringArray(2) = "b"
StringArray(3) = "c"
StringArray(4) = "d"
StringArray(5) = "e"


here the array length (in present case, which is '5') is basically a variable. Now what I want is to add all the array elements and put them as: "a, b, c, d, e".

Is there any direct way to achieve that?

Thanks and regards,

snb
11-20-2012, 05:36 AM
sn=split("a|b|c|d|e","|")

or

sn = [index(char(96 +row(1:5)),)]

or


sn = [transpose(char(96 +row(1:5)))]

GarysStudent
11-20-2012, 05:38 AM
Use Join:

Sub luxation()
Dim StringArray(1 To 5) As String
Dim st As String
StringArray(1) = "a"
StringArray(2) = "b"
StringArray(3) = "c"
StringArray(4) = "d"
StringArray(5) = "e"
st = Join(StringArray, ", ")
MsgBox st
End Sub

arrun
11-20-2012, 10:57 AM
Thanks snb and GarysStudent for your help. GarysStudent's suggestion really served my purpose. Also thanking snb for looking into my problem.