Hallo ,
Ben al een tijdje bezig om de progressbar te laten lopen volgens mijn formule.
maar het werk niet in combinatie met AS2, in AS2 word namelijk een aantal
uitgevoerde berekeningen(totaal 25) opgeteld. De telling word in een aparte module( tijden_Calculate) uitgevoerd dat werkt perfect. Maar als ik dit in combinatie doe met progressbar dan word er niet getelt(AS2=0) en progressbar =0%. Maar als ik nu handmatig een 1 in AS2 invoer en start de telling dan blijft AS2 =1 maar progressbaar = 4%
Kan iemand me vertellen wat ik fout doe ?
Sub ShowUserForm()
UserForm1.Show
End Sub
Sub Main()
Dim Counter As Integer
Dim CalcMax As Integer
Dim r As Integer
Dim PctDone As Single
Application.ScreenUpdating = False
' Initialize variables.
CalcMax = 25
r = Range("AS2")
' Loop through cells.
Do
Do While Counter < 25
Counter = r * 1
' Update de aantal voltooide procenten .
PctDone = Counter / CalcMax
' Roep subroutine om progress bar te update.
UpdateProgressBar PctDone
If Counter = 25 Then
Check = False
Exit Do
' de taak is klaar waneer counter=25, zo unload de UserForm.
End If
Loop
Loop Until Counter = 25
Unload UserForm1
End Sub
Sub UpdateProgressBar(PctDone As Single)
With UserForm1
' Update the Caption property of the Frame control.
.FrameProgress.Caption = Format(PctDone, "0%")
' Widen the Label control.
.Labelprogress.Width = PctDone * _
(.FrameProgress.Width - 10)
End With
' The DoEvents allows the UserForm to update.
DoEvents
End Sub
Sub tijden_Calculate()
myUnLockJan
OKCancel = MsgBox("Er word 25 berekeningen uitgevoerd, zie op beeldscherm de aantal uigevoerde berekeningen. Druk op OK om verder te gaan om berekening uit te voeren of op annuleren om af te sluiten.", vbOKCancel + vbQuestion, "Kims Uren")
Select Case OKCancel
Case vbOK
GoTo 333
Case vbCancel
GoTo 444
End Select
333:
ShowUserForm
Application.ScreenUpdating = False
TijdVanD5_10
mycount = 1
Range("AS2") = mycount
Application.ScreenUpdating = True
Application.ScreenUpdating = False
TijdVanH5_10
mycount = 2
Range("AS2") = mycount
Application.ScreenUpdating = True
Application.ScreenUpdating = False
TijdVanL5_10
mycount = 3
Range("AS2") = mycount
Application.ScreenUpdating = True
Application.ScreenUpdating = False
TijdVanP5_10
mycount = 4
Range("AS2") = mycount
Application.ScreenUpdating = True
Application.ScreenUpdating = False
TijdVanT5_10
mycount = 5
Range("AS2") = mycount
Application.ScreenUpdating = True
Application.ScreenUpdating = False
TijdVanD12_17
mycount = 6
Range("AS2") = mycount
Application.ScreenUpdating = True
Application.ScreenUpdating = False
TijdVanH12_17
mycount = 7
Range("AS2") = mycount
Application.ScreenUpdating = True
Application.ScreenUpdating = False
TijdVanL12_17
mycount = 8
Range("AS2") = mycount
Application.ScreenUpdating = True
Application.ScreenUpdating = False
TijdVanP12_17
mycount = 9
Range("AS2") = mycount
Application.ScreenUpdating = True
Application.ScreenUpdating = False
TijdVanT12_17
mycount = 10
Range("AS2") = mycount
Application.ScreenUpdating = True
Application.ScreenUpdating = False
TijdVanD19_24
mycount = 11
Range("AS2") = mycount
Application.ScreenUpdating = True
Application.ScreenUpdating = False
TijdVanH19_24
mycount = 12
Range("AS2") = mycount
Application.ScreenUpdating = True
Application.ScreenUpdating = False
TijdVanL19_24
mycount = 13
Range("AS2") = mycount
Application.ScreenUpdating = True
Application.ScreenUpdating = False
TijdVanP19_24
Range("AS2") = mycount
Application.ScreenUpdating = True
Application.ScreenUpdating = False
TijdVanT19_24
mycount = 15
Range("AS2") = mycount
Application.ScreenUpdating = True
Application.ScreenUpdating = False
TijdVanD26_31
mycount = 16
Range("AS2") = mycount
Application.ScreenUpdating = True
Application.ScreenUpdating = False
TijdVanH26_31
mycount = 17
Range("AS2") = mycount
Application.ScreenUpdating = True
Application.ScreenUpdating = False
TijdVanL26_31
Range("AS2") = mycount
Application.ScreenUpdating = True
Application.ScreenUpdating = False
TijdVanP26_31
mycount = 19
Range("AS2") = mycount
Application.ScreenUpdating = True
Application.ScreenUpdating = False
TijdVanT26_31
mycount = 20
Range("AS2") = mycount
Application.ScreenUpdating = True
Application.ScreenUpdating = False
TijdVanD33_38
mycount = 21
Range("AS2") = mycount
Application.ScreenUpdating = True
Application.ScreenUpdating = False
TijdVanH33_38
Range("AS2") = mycount
Application.ScreenUpdating = True
Application.ScreenUpdating = False
TijdVanL33_38
mycount = 23
Range("AS2") = mycount
Application.ScreenUpdating = True
Application.ScreenUpdating = False
TijdVanP33_38
mycount = 24
Range("AS2") = mycount
Application.ScreenUpdating = True
Application.ScreenUpdating = False
TijdVanT33_38
mycount = 25
Range("AS2") = mycount
MsgBox "Alle 25 berekeningen zijn uitgevoerd voor deze maand", vbInformation, "Kims Uren"
mycount = 0
Application.ScreenUpdating = False
Range("AS4").Value = Date + Time
Application.ScreenUpdating = True
Range("AS2") = mycount
myLock
444:
''TijdTot
End Sub[/COLOR]
Ben al een tijdje bezig om de progressbar te laten lopen volgens mijn formule.
maar het werk niet in combinatie met AS2, in AS2 word namelijk een aantal
uitgevoerde berekeningen(totaal 25) opgeteld. De telling word in een aparte module( tijden_Calculate) uitgevoerd dat werkt perfect. Maar als ik dit in combinatie doe met progressbar dan word er niet getelt(AS2=0) en progressbar =0%. Maar als ik nu handmatig een 1 in AS2 invoer en start de telling dan blijft AS2 =1 maar progressbaar = 4%
Kan iemand me vertellen wat ik fout doe ?
Sub ShowUserForm()
UserForm1.Show
End Sub
Sub Main()
Dim Counter As Integer
Dim CalcMax As Integer
Dim r As Integer
Dim PctDone As Single
Application.ScreenUpdating = False
' Initialize variables.
CalcMax = 25
r = Range("AS2")
' Loop through cells.
Do
Do While Counter < 25
Counter = r * 1
' Update de aantal voltooide procenten .
PctDone = Counter / CalcMax
' Roep subroutine om progress bar te update.
UpdateProgressBar PctDone
If Counter = 25 Then
Check = False
Exit Do
' de taak is klaar waneer counter=25, zo unload de UserForm.
End If
Loop
Loop Until Counter = 25
Unload UserForm1
End Sub
Sub UpdateProgressBar(PctDone As Single)
With UserForm1
' Update the Caption property of the Frame control.
.FrameProgress.Caption = Format(PctDone, "0%")
' Widen the Label control.
.Labelprogress.Width = PctDone * _
(.FrameProgress.Width - 10)
End With
' The DoEvents allows the UserForm to update.
DoEvents
End Sub
Sub tijden_Calculate()
myUnLockJan
OKCancel = MsgBox("Er word 25 berekeningen uitgevoerd, zie op beeldscherm de aantal uigevoerde berekeningen. Druk op OK om verder te gaan om berekening uit te voeren of op annuleren om af te sluiten.", vbOKCancel + vbQuestion, "Kims Uren")
Select Case OKCancel
Case vbOK
GoTo 333
Case vbCancel
GoTo 444
End Select
333:
ShowUserForm
Application.ScreenUpdating = False
TijdVanD5_10
mycount = 1
Range("AS2") = mycount
Application.ScreenUpdating = True
Application.ScreenUpdating = False
TijdVanH5_10
mycount = 2
Range("AS2") = mycount
Application.ScreenUpdating = True
Application.ScreenUpdating = False
TijdVanL5_10
mycount = 3
Range("AS2") = mycount
Application.ScreenUpdating = True
Application.ScreenUpdating = False
TijdVanP5_10
mycount = 4
Range("AS2") = mycount
Application.ScreenUpdating = True
Application.ScreenUpdating = False
TijdVanT5_10
mycount = 5
Range("AS2") = mycount
Application.ScreenUpdating = True
Application.ScreenUpdating = False
TijdVanD12_17
mycount = 6
Range("AS2") = mycount
Application.ScreenUpdating = True
Application.ScreenUpdating = False
TijdVanH12_17
mycount = 7
Range("AS2") = mycount
Application.ScreenUpdating = True
Application.ScreenUpdating = False
TijdVanL12_17
mycount = 8
Range("AS2") = mycount
Application.ScreenUpdating = True
Application.ScreenUpdating = False
TijdVanP12_17
mycount = 9
Range("AS2") = mycount
Application.ScreenUpdating = True
Application.ScreenUpdating = False
TijdVanT12_17
mycount = 10
Range("AS2") = mycount
Application.ScreenUpdating = True
Application.ScreenUpdating = False
TijdVanD19_24
mycount = 11
Range("AS2") = mycount
Application.ScreenUpdating = True
Application.ScreenUpdating = False
TijdVanH19_24
mycount = 12
Range("AS2") = mycount
Application.ScreenUpdating = True
Application.ScreenUpdating = False
TijdVanL19_24
mycount = 13
Range("AS2") = mycount
Application.ScreenUpdating = True
Application.ScreenUpdating = False
TijdVanP19_24
Range("AS2") = mycount
Application.ScreenUpdating = True
Application.ScreenUpdating = False
TijdVanT19_24
mycount = 15
Range("AS2") = mycount
Application.ScreenUpdating = True
Application.ScreenUpdating = False
TijdVanD26_31
mycount = 16
Range("AS2") = mycount
Application.ScreenUpdating = True
Application.ScreenUpdating = False
TijdVanH26_31
mycount = 17
Range("AS2") = mycount
Application.ScreenUpdating = True
Application.ScreenUpdating = False
TijdVanL26_31
Range("AS2") = mycount
Application.ScreenUpdating = True
Application.ScreenUpdating = False
TijdVanP26_31
mycount = 19
Range("AS2") = mycount
Application.ScreenUpdating = True
Application.ScreenUpdating = False
TijdVanT26_31
mycount = 20
Range("AS2") = mycount
Application.ScreenUpdating = True
Application.ScreenUpdating = False
TijdVanD33_38
mycount = 21
Range("AS2") = mycount
Application.ScreenUpdating = True
Application.ScreenUpdating = False
TijdVanH33_38
Range("AS2") = mycount
Application.ScreenUpdating = True
Application.ScreenUpdating = False
TijdVanL33_38
mycount = 23
Range("AS2") = mycount
Application.ScreenUpdating = True
Application.ScreenUpdating = False
TijdVanP33_38
mycount = 24
Range("AS2") = mycount
Application.ScreenUpdating = True
Application.ScreenUpdating = False
TijdVanT33_38
mycount = 25
Range("AS2") = mycount
MsgBox "Alle 25 berekeningen zijn uitgevoerd voor deze maand", vbInformation, "Kims Uren"
mycount = 0
Application.ScreenUpdating = False
Range("AS4").Value = Date + Time
Application.ScreenUpdating = True
Range("AS2") = mycount
myLock
444:
''TijdTot
End Sub[/COLOR]