10-19-2023, 12:42 AM
(10-19-2023, 12:37 AM)Kernelpanic Wrote: As I mentioned - The first example would also result in 101, but due to the declaration there is an error message: "Out of range".
The declaration doesn't give out of range. You get out of range by trying to access an element which is beyond the scope of your dimmed array.
Take a quick look at the example here and see how many elements each array has:
Code: (Select All)
'This is my Program code area
Cls
DoStuff
DoStuff2
''$INCLUDE:'my file holding the library stuff below:
Sub DoStuff 'This is my poorly illustrated SUB for use in a Library
Option Base 1
Dim AppleJuiceSales(100)
Print LBound(AppleJuiceSales), UBound(AppleJuiceSales)
Print "Number of Elements: "; UBound(AppleJuiceSales) - LBound(AppleJuiceSales) + 1
End Sub
Sub DoStuff2
Option Base 0
Dim AppleJuiceSales(100)
Print LBound(AppleJuiceSales), UBound(AppleJuiceSales)
Print "Number of Elements: "; UBound(AppleJuiceSales) - LBound(AppleJuiceSales) + 1
End Sub