Redefine static variable : Static variable « Language Basics « VBA / Excel / Access / Word






Redefine static variable

 

Sub Scope1()
  Static Sales
  Sales = Sales + 1
  MsgBox Sales
End Sub

Sub Scope2()
  Static Sales
  Sales = Sales + 10
  MsgBox Sales
End Sub

 








Related examples in the same category

1.If you need a procedural level variable to retain its value between calls to the procedure, declare the variable using the Static keyword
2.Static variable lifetime
3.Static Variables: A Special Type of Local Variable