Dear All
I have downloaded a progress meter bar from http://www.andypope.info/vba/pmeter.htm and build my calculations inside using a simple straight-line indicator – “Bar”.
Using Step-by-Step “F8” execution on each line it works perfect.
Unfortunately by automatic execution on the whole code the UserForm1 appears on the screen with 0% meter reading and stays the same to finishing calculation. And later disappear.
Does somebody solve a similar problem?
'Option Explicit
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Sub UserForm_Initialize()
labPg1.Tag = labPg1.Width
labPg1.Width = 0
End Sub
Private Sub CommandButton2_Click()
Application.Cursor = xlWait
DemoProgress1
Application.Cursor = xlDefault
End Sub
Sub Calculate(i)
F = 10 ^i
Ac = GetTLAn(F)
mRes(1, i) = Ac
mRes(0, i) = F
End Sub
Sub DemoProgress1()
Dim intIndex As Integer
Dim sngPercent As Single
Dim intMax As Integer
Dim i As Integer
Size = ND * PD + 1
intMax = Size
For i = BF To ND * PD + 1
intIndex = i
Calculate (i)
sngPercent = intIndex / intMax
labPg1v.Caption = PAD & Format(sngPercent, "0%")
labPg1va.Caption = labPg1v.Caption
labPg1va.Width = labPg1.Width
labPg1.Width = Int(labPg1.Tag * sngPercent)
Application.ScreenUpdating = True
Sleep 10
Next i
Unload Me
End Sub
Private Sub CommandButton1_Click()
Unload Me
End Sub
I have downloaded a progress meter bar from http://www.andypope.info/vba/pmeter.htm and build my calculations inside using a simple straight-line indicator – “Bar”.
Using Step-by-Step “F8” execution on each line it works perfect.
Unfortunately by automatic execution on the whole code the UserForm1 appears on the screen with 0% meter reading and stays the same to finishing calculation. And later disappear.
Does somebody solve a similar problem?
'Option Explicit
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Sub UserForm_Initialize()
labPg1.Tag = labPg1.Width
labPg1.Width = 0
End Sub
Private Sub CommandButton2_Click()
Application.Cursor = xlWait
DemoProgress1
Application.Cursor = xlDefault
End Sub
Sub Calculate(i)
F = 10 ^i
Ac = GetTLAn(F)
mRes(1, i) = Ac
mRes(0, i) = F
End Sub
Sub DemoProgress1()
Dim intIndex As Integer
Dim sngPercent As Single
Dim intMax As Integer
Dim i As Integer
Size = ND * PD + 1
intMax = Size
For i = BF To ND * PD + 1
intIndex = i
Calculate (i)
sngPercent = intIndex / intMax
labPg1v.Caption = PAD & Format(sngPercent, "0%")
labPg1va.Caption = labPg1v.Caption
labPg1va.Width = labPg1.Width
labPg1.Width = Int(labPg1.Tag * sngPercent)
Application.ScreenUpdating = True
Sleep 10
Next i
Unload Me
End Sub
Private Sub CommandButton1_Click()
Unload Me
End Sub