Answers for "vba public variable"

VBA
0

vba static variable

' Static variable inside a function
Function MyStaticFunction(ByVal pToAdd As Integer) As Integer
    Static iStatic As Integer       ' Keeps its value between calls
    iStatic = iStatic + pToAdd
    MyStaticFunction = iStatic
End Function
'---------------------------------------------------------------------
Sub TesMe()
  Debug.Print MyStaticFunction(1)	' 1
  Debug.Print MyStaticFunction(3)	' 4
End Sub
Posted by: Guest on January-22-2021

Code answers related to "VBA"

Browse Popular Code Answers by Language