How do i make a progress keep moving to 100% with a timer liek every 10 seconds?
Printable View
How do i make a progress keep moving to 100% with a timer liek every 10 seconds?
What is the total time?
EG. Do you want the progress bar to progress at a 10 second rate, up till 60 seconds?
EG:
VB Code:
Option Explicit Private Sub Form_Load() 'Set up ProgressBar1.Min = 0 ProgressBar1.Max = 10 ProgressBar1.Value = 0 Timer1.Interval = 1000 '1 second Timer1.Enabled = True End Sub Private Sub Timer1_Timer() If ProgressBar1.Value >= 10 Then 'When max is reached, disable Timer Timer1.Enabled = False Else ProgressBar1.Value = ProgressBar1.Value + 1 End If End Sub
I tryed to let it run with a vbyesno msgbox but it closes wether i click yes or no.
Post your code.
VB Code:
Option Explicit Private Sub Form_Load() MsgBox " Would you like to install MasterControl", _ vbYesNo, "MasterControl" If vbYes Then ProgressBar1.Min = 0 ProgressBar1.Max = 20 ProgressBar1.Value = 0 Timer1.Interval = 1000 Timer1.Enabled = True End If If vbNo Then End End If End Sub Private Sub Timer1_Timer() If ProgressBar1.Value >= 20 Then Timer1.Enabled = False Else ProgressBar1.Value = ProgressBar1.Value + 1 End If End Sub
Like:
VB Code:
Option Explicit Private Sub Form_Load() If MsgBox("Would you like to install MasterControl", vbYesNo [b]+ vbQuestion[/b], "MasterControl") = vbYes Then ProgressBar1.Min = 0 ProgressBar1.Max = 20 ProgressBar1.Value = 0 Timer1.Interval = 1000 Timer1.Enabled = True Else ProgressBar1.Visible = False End If End Sub Private Sub Timer1_Timer() If ProgressBar1.Value >= 20 Then Timer1.Enabled = False Else ProgressBar1.Value = ProgressBar1.Value + 1 End If End Sub
VB Code:
Private Sub Form_Load() if MsgBox(" Would you like to install MasterControl", _ vbYesNo, "MasterControl") = vbYes Then ProgressBar1.Min = 0 ProgressBar1.Max = 20 ProgressBar1.Value = 0 Timer1.Interval = 1000 Timer1.Enabled = True Else ' vbNo Unload Me 'DO NOT USE E ND End If End Sub
thanks braille i guess i was posting whenever you do it works fine.
Using Unload Me as BrailleSchool mentioned:
VB Code:
Option Explicit Private Sub Form_Load() If MsgBox("Would you like to install MasterControl", vbYesNo + vbQuestion, "MasterControl") = vbYes Then ProgressBar1.Min = 0 ProgressBar1.Max = 20 ProgressBar1.Value = 0 Timer1.Interval = 1000 Timer1.Enabled = True Else Unload Me End If End Sub Private Sub Timer1_Timer() If ProgressBar1.Value >= 20 Then Timer1.Enabled = False Unload Me Else ProgressBar1.Value = ProgressBar1.Value + 1 End If End Sub