-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathProgressBar.cls
68 lines (61 loc) · 1.76 KB
/
ProgressBar.cls
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
END
Attribute VB_Name = "ProgressBar"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Public msg As String
Public progress As Long
Public goal As Long
Public form As UserForm
Public startDate As Date
Private Sub Class_Initialize()
progress = 0
Set form = ProgressForm
startDate = vbNull
End Sub
Private Sub Class_Terminate()
ProgressForm.Hide
End Sub
Public Sub Init(Optional pMsg As String = vbNullString, Optional pGoal As Integer = -1, Optional pTimer As Boolean = False, Optional pProgress As Integer = -1)
Dim startMsg As String
startMsg = ""
If pGoal >= 0 Then
goal = pGoal
End If
If pProgress >= 0 Then
progress = pProgress
End If
If pTimer Then
startDate = Now()
startMsg = "00:00 - "
End If
If pMsg <> vbNullString Then
msg = pMsg
form.MsgBox.Caption = CStr(msg & "..." & vbCrLf & vbCrLf & startMsg & CStr((progress * 100) \ goal) & " %")
End If
End Sub
Public Sub Update(Optional steps As Integer = 1)
progress = progress + steps
Dim startMsg As String
If startDate = vbNull Then
startMsg = ""
Else
Dim seconds As Integer, minutes As Integer
seconds = DateDiff("s", startDate, Now())
minutes = seconds \ 60
seconds = seconds - minutes * 60
startMsg = Format$(minutes, "00") & ":" & Format$(seconds, "00") & " - "
End If
form.MsgBox.Caption = CStr(msg & "..." & vbCrLf & vbCrLf & startMsg & CStr((progress * 100) \ goal) & " %")
form.Repaint
End Sub
Public Sub UpdateMessage(message As String)
msg = message
End Sub
Public Sub CloseForm()
ProgressForm.Hide
End Sub