Hi Matt, no, I have no actual data to back this up. My main problem with the practice of declaring a variable inside a loop
comes from debugging problems that I have found with other programmers code
and my own when I have tired doing that. I also find code much more readable(personal opinion) by putting declarations either
at the top of a sub, or if they are public to a Class, at the top of the class.
And that was the way I re-learned to do it,,,,,,,,,,,,,,,,,after finding problems doing it the other way.
but, to each his own. And in places I have worked, declaring variables etc. inside a loop were/are a no-no.
james
"Matt Berther" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
> Hello james,
>
> Do you have any data to back this up?
>
> --
> Matt Berther
> http://www.mattberther.com
>
>> Less efficient and also considered poor coding practice. james
>>
>> "vbMental" <(E-Mail Removed)> wrote in message
>> news:3C4698A0-2DB3-47C0-9B16-(E-Mail Removed)...
>>
>>> Is it less efficient to declare variables inside loops like this:
>>>
>>> For I = 1 to 1000000000000
>>> Dim num as integer
>>> ........(using num here)......
>>> Next I
>>> Versus declaring outside the loop like this:
>>>
>>> Dim num as integer
>>> For I = 1 to 1000000000000
>>> ........(using num here)......
>>> Next I
>>> It looks as if the first one would keep re-allocating and releasing
>>> memory for the variable...
>>>
>
>
>