Answer by StayOnTarget for What are the risks of declaring a variable in the...
I would try to declare variables in a location that conveys useful information to the next programmer, over and above being functionally correct. This normally means: follow the scoping rules of the...
View ArticleAnswer by PChemGuy for What are the risks of declaring a variable in the...
Declare your variables, when you actually need them. When you have all declarations lumped at the top of the procedure, refactoring becomes much harder. And when you want to double check your...
View ArticleAnswer by GSerg for What are the risks of declaring a variable in the middle...
There are no risks of declaring it in the middle.The effect of declaring a variable in the middle is that it can only be used after that point and not before (which is scope).The lifetime of the...
View ArticleAnswer by Ahmad for What are the risks of declaring a variable in the middle...
Declaring your variables up front, at the top of your sub/function makes it easy for others (and perhaps for you if you come by the code after, say a month) to read and understand what your code needs...
View ArticleWhat are the risks of declaring a variable in the middle of the code?
I usually see in almost all of VBA codes all variables are declared after e.g. Sub/Function name lineI know and I used variable declaration in the middle of some of my codes (Not inside a loop) and saw...
View Article