View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
RyanH RyanH is offline
external usenet poster
 
Posts: 586
Default Automatically resest variable values = 0 after runtime

I have about 40 variables at the top of a Userforms Declaration section. I
do this because I need the variables calculated in one procedure and made
available to another procedure when they are all done being calulated.

The problem is I currently have to write code to reset all the variables
back to 0 before they are recalculated. If there a way to declare the
variable (DataType Single) = 0 at the beginning of runtime. For example:

Option Explicit

Dim var1 As Single = 0
Dim var2 As Single = 0

Private Sub CalculateVariables()

' code to calculate var1 & var2

End Sub

Private Sub UseVariables

' code to use var1 & var2

End Sub

After runtime var1 & var2 are reset to 0
--
Cheers,
Ryan