Static variable lifetime : Static variable « Language Basics « VBA / Excel / Access / Word






Static variable lifetime

 
Sub LifeTime()
  Static Sales
  Sales = Sales + 1
  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 Variables: A Special Type of Local Variable
3.Redefine static variable