Silly VB question

Just a syntax question, since I don’t have MSDN or a book to reference, and I figure one of you peoples must know this:

I want to declare an array of strings. How would I do so? The strings are going to be static and hard-coded.

for instance, say the words are “dog”, “cat”, “fish”, “horse”, and “goat”:

I would want array[0] to be “dog”
array[1] to be “cat”
array[2] to be “fish”
array[3] to be “horse”

I don’t even know if VB arrays start on 1 or 0.

Thanks for your help, my mind is in a C gutter.

Quick way: use the Array function.


Dim SillyArray(4)
SillyArray = Array(“dog”,“cat”,“fish”,“horse”,“goat”)

This will populate your array with SillArray(0) = “dog”…SillyArray(4) = “goat”.

Array subscripts by default start with 0. You can declare a different starting and ending subscript by using lower and upper bounds in the Dim statement.

Dim SillyArray(5 to 9) as String