Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

thermometer display 1

Status
Not open for further replies.

OhioSteve

MIS
Mar 12, 2002
1,352
US
When my users press a button on a form, it starts a process that takes awhile to complete. I need something like a thermometer to show progress on this process.

As my first step, I have created some sample code that displays progess as a percentage. UNFORTUNATELY, it does not work. The textbox remains empty until the very end of the process, and then it displays "100% complete".

Please advise me on this issue.

__________________

Private Sub Command0_Click()
MsgBox "starting test"
Dim a As Long
Dim b As Long
a = 0
b = 0
Do While a < 100000000
If a Mod 1000000 = 0 Then
b = b + 1
myTextBox.value = b & "% complete"
Me.Refresh
End If
a = a + 1
Loop
MsgBox "all done"
End Sub
 
Use the DoEvents function.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
PHV,

Clearly you are a genius! I googled doevents and found just the right code. You get a star.

OhioSteve

sample code for reader:

MsgBox "starting test"
Dim a As Long
Dim b As Long
a = 0
b = 0
myLabel.Visible = True
Do While a < 100000000
If a Mod 1000000 = 0 Then
b = b + 1
DoEvents
myLabel.Caption = b & "% complete"
End If
a = a + 1
Loop
MsgBox "all done
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top