Creating an array of strings

J

John

How do I create a list of strings that I can cycle thru via a for loop
something like this. I can't get the syntax right, not being much of a VB
guy.

Dim List1() as String
List1 = {"aaa", "bbb", "ccc"}
For i = 1 to 3
MsgBox List1(i)
Next

I appreciate your help, -John
 
J

Joel

List need to be a variant or not declared. Arrays by default start at 0 index

Sub test()

Dim List1
List1 = Array("aaa", "bbb", "ccc")
For i = 0 To 2
MsgBox List1(i)
Next

End Sub
 

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