Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Day 026: ERASE
#12
(06-10-2023, 06:28 PM)sivacc Wrote: Hi , I 'm  new here . But have persisting problem  ..I want to dim an array, or redim it in a sub and pass values through sub's parameter list . I get the dim  bounds reading a file ( in the sub) It wont compile. When I print the ubound before redim , I get 10, default size in BASIC it seems. Breaking the sub, declaring  arrays in the main is so awkward. Loads of thanks for a tip or clue ?

You'll want to REDIM the array in the main module, and then resize it as needed in the SUB/FUNCTION.  A quick example is below for you:

Code: (Select All)
ReDim ResizeableArray(10) As Long

Print "Before running our SUB, our array holds"; UBound(ResizeableArray); "Elements."
ExampleResize ResizeableArray()
Print "After running our SUB, our array holds"; UBound(ResizeableArray); "Elements."


Sub ExampleResize (Array() As Long)
    Print "Entering the SUB"
    Print "The original size of this array holds"; UBound(Array); "elements."
    ReDim Array(20) As Long
    Print "The resized size of this array holds"; UBound(Array); "elements."
    Print "Exiting the SUB"
End Sub
Reply


Messages In This Thread
Day 026: ERASE - by Pete - 12-07-2022, 07:24 AM
RE: Day 026: ERASE - by mnrvovrfc - 12-07-2022, 10:39 AM
RE: Day 026: ERASE - by bplus - 12-07-2022, 05:20 PM
RE: Day 026: ERASE - by Pete - 12-07-2022, 05:36 PM
RE: Day 026: ERASE - by bplus - 12-07-2022, 08:18 PM
RE: Day 026: ERASE - by Pete - 12-07-2022, 08:31 PM
RE: Day 026: ERASE - by SMcNeill - 12-07-2022, 10:13 PM
RE: Day 026: ERASE - by mnrvovrfc - 12-07-2022, 10:45 PM
RE: Day 026: ERASE - by Pete - 12-07-2022, 10:54 PM
RE: Day 026: ERASE - by sivacc - 06-10-2023, 06:28 PM
RE: Day 026: ERASE - by TerryRitchie - 06-10-2023, 06:31 PM
RE: Day 026: ERASE - by SMcNeill - 06-10-2023, 06:35 PM
RE: Day 026: ERASE - by bplus - 06-10-2023, 06:39 PM



Users browsing this thread: 3 Guest(s)