|
-
Oct 31st, 2001, 03:00 PM
#1
Thread Starter
Addicted Member
save value as variable
Hi I want the value of the progress bar t obe saved as a variable the second time a user clicks the button, please help! HERES MY CODE:
[Highlight=VB]
Command1.Caption = "Stop the strength O' meter"
Static Quit As Boolean
Dim i As Integer
Dim t As Integer
Quit = Not Quit
If Quit = False Then Exit Sub
i = 1
Do Until Quit = False
DoEvents
If t = 800 Then
ProgressBar2.Value = ProgressBar2.Value + i
If ProgressBar2.Value = ProgressBar2.Max Or ProgressBar2.Value = ProgressBar2.Min Then i = -i
t = 0
End If
t = t + 1
Loop
strength = ProgressBar2.Value
Command1.Enabled = False
everything is made of carbon, except some stuff!!BTW LOOK AT ME PROFILE!!
-
Oct 31st, 2001, 03:16 PM
#2
You can create a global variable in the General Dec section to hold the value. The value won't change throughout the running of the app unless you change it.
-
Oct 31st, 2001, 03:19 PM
#3
Or, as a static variable. This is from the MSDN library:
You can preserve the value of a local variable by making the variable static. Use the Static keyword to declare one or more variables inside a procedure, exactly as you would with the Dim statement:
Static Depth
For example, the following function calculates a running total by adding a new value to the total of previous values stored in the static variable Accumulate:
Function RunningTotal(num)
Static ApplesSold
ApplesSold = ApplesSold + num
RunningTotal = ApplesSold
End Function
If ApplesSold was declared with Dim instead of Static, the previous accumulated values would not be preserved across calls to the function, and the function would simply return the same value with which it was called.
-
Oct 31st, 2001, 04:14 PM
#4
Personally, I would use a static variable (instead of a module-level variable) if you just need it in this sub routine.
-
Nov 1st, 2001, 09:28 AM
#5
Thread Starter
Addicted Member
how
can i do that , btw i just tell you im dumb now so dont make fun of me
everything is made of carbon, except some stuff!!BTW LOOK AT ME PROFILE!!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|