Reputation: 101
What would be an underlying difference in the following aspects of the ensuing two subs:
Sub test1()
Static x As Byte
x = 1
End Sub
Static Sub test2()
Dim y As Byte
y = 2
End Sub
Upvotes: 2
Views: 124
Reputation: 78180
Making the entire procedure Static
is a shortcut for declaring all its local variables Static
.
So there is effectively no difference between the subs, because effectively all their local variables are declared as Static
and as such are preserved between the calls.
But as in both subs you manually overwrite the value to something else right after the variable declaration, the effect of preserving the value does nothing for you.
There is no difference in the scope of the subs (it remains what it was before Static
), or the the scope of the local variables (they remain local).
Upvotes: 1