Understanding and Using Static Variables

A variable declared with the Static keyword is a special type of local variable. Static variables are declared at the procedure level. As opposed to the local variables declared with the Dim keyword, static variables remain in existence and retain their values after termination of the procedure in which they were declared.

The CostOfPurchase procedure (see Hands-On 3-7) demonstrates the use of the Static variable named allPurchase. The purpose of this variable is to keep track of the running total.

0 0

Post a comment