Array Problems

craigachan

Registered User.
Local time
Today, 06:56
Joined
Nov 9, 2007
Messages
285
Can someone help me understand what is wrong with this array code?

Code:
Dim myray(1 to 10) as string
Dim strRay as string
strRay = "1-2-3-4-5-6-7-8-9"
myray() = split(strRay, "-")
 
Dim y as integer
for y = 0 to 9
    msgbox y & ":" & myray(y)
next y

I'm trying to start my array at '1'. So why is there still myray(0)? Shouldn't my array start with 1 and go to 10? I must be missing something. Thanks for your help.
 
A lower bound for an array is established by the "option base" statement in a vba module. If you would like your Array to start at Element number one, you need to add "Option Base 1" at the top of your module.
 

Users who are viewing this thread

Back
Top Bottom