Using the Language Real Basic I was able to add elements to an array like this
I haven't had any luck finding similar functionality in VBA, so I tried writing a Sub.
I can't get the Sub to work, I believe because UBound(StuffThisArray) is Nil the first go around.
I know it could be done like this Test = Array("Blah Blah 0", "Blah Blah 1", "Blah Blah 2"), but I don't know all of the strings I'll be adding at once and was hoping to avoid sArrayElements = sArrayElements & "," & sNewElement. Any suggestions?
Wow, I'm having amnesia and deja vu at the same time.
I think I've forgotten this before.
Code:
'Real Basic Code
Dim Test() As String
'Here's how I'm used to doing it
Test.Append "Blah Blah 0"
Test.Append "Blah Blah 1"
Test.Append "Blah Blah 2"
I haven't had any luck finding similar functionality in VBA, so I tried writing a Sub.
Code:
Sub Main()
Dim Test() As String
For x = 0 To 2
'Attempt at workaround
Call StuffArray(Test, "Blah Blah" & Str(x))
MsgBox Test(x)
Next
End Sub
Sub StuffArray(ByRef StuffThisArray As Variant, sStuffThis As String)
ReDim Preserve StuffThisArray(UBound(StuffThisArray) + 1)
StuffThisArray(UBound(StuffThisArray)) = sStuffThis
End Sub
I can't get the Sub to work, I believe because UBound(StuffThisArray) is Nil the first go around.
I know it could be done like this Test = Array("Blah Blah 0", "Blah Blah 1", "Blah Blah 2"), but I don't know all of the strings I'll be adding at once and was hoping to avoid sArrayElements = sArrayElements & "," & sNewElement. Any suggestions?
![[thumbsup2] [thumbsup2] [thumbsup2]](/data/assets/smilies/thumbsup2.gif)
I think I've forgotten this before.