12-05-2023, 01:43 PM
(12-05-2023, 01:35 PM)FellippeHeitor Wrote: Wrap variables in parenthesis when passing to a sub. That makes it go byval rather than byref.
Just be warned -- there are a few instances where doing this will cause issues with your program. (I think it's with strings, or arrays of strings, or some such similar which errors out and doesn't work, and we haven't came up with a fix for the issue yet.)
The best practice, if you know you're always going to be passing into a sub BYVAL, is just to pass to temp variables first:
Code: (Select All)
SUB foo (tempX, tempY)
x = tempX
y = tempY
With the above, you'll never pass values back and forth, so you never have to worry about corrupting your original variables.