Static .. SHadows

ah - so basically
if you say

sub button1.click
dim x as integer
x+=1
msgbox(x)
end sub

youll get 1 every time you click the button becuase its dimmed again..

but

sub button1.click
Static x as integer
x+=1
msgbox(x)
end sub

each time you click the button x getes incremented by 1 and it displays 1,2,3,4.. etc

hopefully i understood that correctly
 
Yup, thats exactly it.

The way I look at it is its a combination of a local variable (its only accessable to the currently method) and one with class scope (it value is held between method calls).

Its a pretty useful thang.
 
Back
Top