Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Best Practice for Library Building and Toolboxes
#21
(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".

[Image: Out-of-range2023-10-19-023505.jpg]

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
Reply
#22
`OPTION BASE` and `DEFLNG` are both lazy and horrible.
Tread on those who tread on you

Reply




Users browsing this thread: 1 Guest(s)