Mega Code Archive

 
Categories / VisualBasic Script / Language Basics
 

Understanding and Using Static Variables

Sub CostOfPurchase()     ' declare variables     Static allPurchase     Dim newPurchase As String     Dim purchCost As Single     newPurchase = InputBox("Enter the cost of a purchase:")     purchCost = CSng(newPurchase)     allPurchase = allPurchase + purchCost     ' display results     MsgBox "The cost of a new purchase is: " & newPurchase     MsgBox "The running cost is: " & allPurchase End Sub