What are pros & cons of Passed Arrays vs Global Arrays in Excel VBA -


OK, there is a second attempt to write a stack overprill question, so forgive me if it sounds familiar

I am rewriting an Excel Macro that was created during the period of 2 1/2 years, Frankenstein style (added in laminate). One of the things I need, once loads the data in the array and only once for data accuracy and speed. For the level of my skill I am going to stick with the array method.

My two approaches are as follows:

  • Use Global Dimmed Dynamic Array
  • Reduce the dynamic array in my main process and call them

So, what are the two types of stack overflow that professionals have to take on the opposition? Thanks, Craig ...

First of all, to answer the question that you specifically Do not ask: Set up a custom class and load data in it seriously, you will thank me later.

OK, on ​​your question. I am starting to limit as much scope as possible. This means that I am exceeding the variables between the processes when you have the most restrictive scope in all your variables, then you fall into the lowest problems below the line.

Once a variable passes in two levels, (calling process for 1 tier, from second to second class), then I am starting to take a vital look at my structure. (But not always) If all the three processes are in the same module, then I will make a module-level variable (use private keyword instead of dim). If you distinguish your module correctly (without arbitrary), you can make module-level variables at no risk.

There are some variables that always have global rights from the beginning: variables that contain the app's name and app; The top-level class module, which is running the app, will not lose the scope; Constants (I know that they are not variables) that catch things like commandbar names, I know that I want this global, so they start like that.

I am going out on one organ and say that module-level variables do not ever go into global variables. Global variables start the same way because their nature is the use of module-level variables It seems cumbersome, so maybe this is possible because I've split a module for some good reason or I need to reconsider my whole structure.

Not to say that I have never cheated when I should not have used a global then we have done all this and if you do it then you do not lose any sleep needed.

Then book this post properly: I use custom sections because

  ActiveCell.Value = Invoice.LocalSalesTaxAmount  
< P> Very good to debug

  ActiveCell.Value = anInvoice (35,2)  

Just when you think that with a custom class You need more skill to work - so I did bullet and it could happen to anyone else.


Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -