10-18-2023, 10:33 PM
You guys are missing the point here, completely.
Run the above and see what'll happen with that library code.
Now, run the code below and see what happens:
See why we explicitly define those arrays? LBound has nothing to do with them, nor does UBound. If the user passes you an array via a parameter, then sure, you use LBOUND/UBOUND on them... But if you've got an array built completely inside a sub which your library code is going to use, *EXPLICITLY DEFINE THAT ARRAY*.
Code: (Select All)
'This is my Program code area
Option Base 1
Cls
DoStuff
''$INCLUDE:'my file holding the library stuff below:
Sub DoStuff 'This is my poorly illustrated SUB for use in a Library
Dim AppleJuiceSales(100)
For i = 0 To 100
Print AppleJuiceSales(i)
Next
End Sub
Run the above and see what'll happen with that library code.
Now, run the code below and see what happens:
Code: (Select All)
'This is my Program code area
Option Base 1
Cls
DoStuff
''$INCLUDE:'my file holding the library stuff below:
Sub DoStuff 'This is my poorly illustrated SUB for use in a Library
Dim AppleJuiceSales(0 To 100)
For i = 0 To 100
Print AppleJuiceSales(i)
Next
End Sub
See why we explicitly define those arrays? LBound has nothing to do with them, nor does UBound. If the user passes you an array via a parameter, then sure, you use LBOUND/UBOUND on them... But if you've got an array built completely inside a sub which your library code is going to use, *EXPLICITLY DEFINE THAT ARRAY*.