Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Best Practice for Library Building and Toolboxes
#16
You guys are missing the point here, completely.

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*.
Reply


Messages In This Thread
RE: Best Practice for Library Building and Toolboxes - by SMcNeill - 10-18-2023, 10:33 PM



Users browsing this thread: 1 Guest(s)