ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Duplication of variables in declarations area and procedure argume (https://www.excelbanter.com/excel-programming/409208-duplication-variables-declarations-area-procedure-argume.html)

forger

Duplication of variables in declarations area and procedure argume
 
I needed to break up a long main procedure into sub procedures because of the
64K limit. The number of array variables needed for input to the spun-off
subprocedure were too many to fit into the sub arguments, because of the 21
continuation line limit, so I moved the array declarations into the General
Declarations Area above the main procedure, so that they would not need to be
passed in the arguments of the spun-off subprocedure. So far so good.
However, some of these arrays were already being passed thru the arguments of
other subprocedures in the program (which is all in one Worksheet Module). I
expected the compiler to complain and hilight the duplicate declarations (in
the General Declarations Area and sub arguments), but it didn't, and
compiled. I stepped thru the program: no problems so far.
Is this OK? I think that the reason why it works is because arrays are
passed ByRef, so the compiler doesn't care how the arrays are referenced, as
long as it knows where they are in memory. But I would like to be reassured
that this practice is OK.

It would be a laborious process to find all sub array arguments which are in
the General Declarations Area for all subs in the program, in order to remove
them from the arguments. And if it is unnecessary, then why bother? You know:
if it ain't broke, then don't fix it.


All times are GMT +1. The time now is 05:32 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com