' Name: VBA Progressbar (Frm73) (By: ANmarAmdeen on 5/16/2018 11:19:00 AM) ' Language: VBA | Category: UI ' Tags: UserInterface, Progress, Box ' Parameters: Val1Main, Val9Main, Val1Small, Val9Small, MainMsg, SmallMsg ' ' Attachments: 2 ' Link: http://MyDev.net/?DevID=E6FETR1UQR ' ' Description: Progress bar Frm73 or just simple message
Declare Public CancelIt in a module
After every Frm73.Update, if CancelIt=1 then user requested to cancel process
Initialize, have to call it first:
Frm73.Reset

End it:
Frm73.Endd

Show certain percintage:
Frm73.Update 220,500,27,40,"Main message","Small secondary message"
Or:
Frm73.Update 220,500,,,"Only main bar"

Zip file contains .frm and .frx files to drop into your VBA project
Or:
Frm73.Update 0,0, 3 , 13 ,"Only small bar"
Or:
Frm73.Update 0,0,,,"Large message" , "And another small message " ' Private Sub CmdClose_Click() CancelIt = 1 End Sub Sub Reset() CancelIt = 0 Lbl_Main.Caption = "Loading ..." Lbl_Small.Caption = "" Lbl_PrgMain.Width = 0 Lbl_PrgSmall.Width = 0 Frm73.Show 0 DoEvents End Sub Sub Update(Val1Main, Val9Main, Optional Val1Small = 0, Optional Val9Small = 0, _ Optional MainMsg = "Reading...", _ Optional SmallMsg = "") MainW = 0 Messag = MainMsg If Val9Main > 0 Then MainW = (Lbl_Main.Width - 2) * Val1Main / Val9Main Messag = MainMsg & " " & Int(Val1Main * 100 / Val9Main) & _ "% (" & Format(Val1Main, "#,0") & " / " & Format(Val9Main, "#,0") & ")" End If Lbl_PrgMain.Width = MainW Lbl_Main.Caption = Messag SmallW = 0 If Val9Small > 0 Then SmallW = (Lbl_Main.Width - 2) * Val1Small / Val9Small Lbl_PrgSmall.Width = SmallW Lbl_Small.Caption = SmallMsg DoEvents 'If CancelIt = 1 Then Endd End Sub Sub Endd() Unload Me End Sub

VBA Progressbar (Frm73)

Progress bar Frm73 or just simple message
Declare Public CancelIt in a module
After every Frm73.Update, if CancelIt=1 then user requested to cancel process
Initialize, have to call it first:
Frm73.Reset

End it:
Frm73.Endd

Show certain percintage:
Frm73.Update 220,500,27,40,"Main message","Small secondary message"
Or:
Frm73.Update 220,500,,,"Only main bar"

Zip file contains .frm and .frx files to drop into your VBA project
Or:
Frm73.Update 0,0, 3 , 13 ,"Only small bar"
Or:
Frm73.Update 0,0,,,"Large message" , "And another small message "

Private Sub CmdClose_Click()
CancelIt = 1
End Sub
Sub Reset()
CancelIt = 0
Lbl_Main.Caption = "Loading ..."
Lbl_Small.Caption = ""
Lbl_PrgMain.Width = 0
Lbl_PrgSmall.Width = 0
Frm73.Show 0
DoEvents
End Sub
Sub Update(Val1Main, Val9Main, Optional Val1Small = 0, Optional Val9Small = 0, _
Optional MainMsg = "Reading...", _
Optional SmallMsg = "")

MainW = 0
Messag = MainMsg
If Val9Main > 0 Then
MainW = (Lbl_Main.Width - 2) * Val1Main / Val9Main
Messag = MainMsg & " " & Int(Val1Main * 100 / Val9Main) & _
"% (" & Format(Val1Main, "#,0") & " / " & Format(Val9Main, "#,0") & ")"
End If
Lbl_PrgMain.Width = MainW
Lbl_Main.Caption = Messag

SmallW = 0
If Val9Small > 0 Then SmallW = (Lbl_Main.Width - 2) * Val1Small / Val9Small
Lbl_PrgSmall.Width = SmallW
Lbl_Small.Caption = SmallMsg

DoEvents
'If CancelIt = 1 Then Endd
End Sub
Sub Endd()
Unload Me
End Sub




ANmarAmdeen
45
Attachments
Tags
UserInterface, Progress, Box
Parameters
Val1Main, Val9Main, Val1Small, Val9Small, MainMsg, SmallMsg
UI VBA