modProgBar

modProgBar

Option Explicit On

Imports System.Windows.Forms

Module modProgBar

Public theProgBar As ProgressBar
Public theProgBarTitle As Label
Public theProgBarTitleMsg As String
Public theCallBtn As Button
Public theCallBtn2 As Button

Public Sub InitProgressBar(ByVal progMsg As String)
theProgBar.Minimum = 0
theProgBar.Maximum = 100
theProgBarTitleMsg = progMsg
theProgBarTitle.Text = progMsg & ” …”
theProgBar.Enabled = True
theProgBarTitle.Enabled = True
theCallBtn.Enabled = False
theCallBtn2.Enabled = False
End Sub

Public Sub StepProgressBar(ByVal thisNum As Long, ByVal totalNum As Long)
Dim currentPercent As Integer
‘currentPercent = Int((thisNum / totalNum) * 100)
currentPercent = modCommon.GetCeiling((thisNum / totalNum) * 100)
theProgBar.Value = currentPercent
theProgBarTitle.Text = theProgBarTitleMsg & ” (” & CStr(currentPercent) & “%) …”
System.Windows.Forms.Application.DoEvents()
End Sub

Public Sub EndProgressDialog(Optional ByVal isStep As Boolean = False)
theProgBar.Value = 0
IIf(isStep, theProgBarTitle.Text = AppName & ” – Step Done!”, theProgBarTitle.Text = AppName & ” – Task Done!”)
theProgBar.Enabled = False
theProgBarTitle.Enabled = False
theCallBtn.Enabled = True
theCallBtn2.Enabled = True
End Sub

End Module

button

With F
theProgBar = .progBar : theProgBar.Enabled = False
theProgBarTitle = .labProgTitle : theProgBarTitle.Text = “” : theProgBarTitle.Enabled = False
theCallBtn = .cmdOK
theCallBtn2 = .cmdCancel

.ShowDialog()

End With

module

Dim runflag As Long
runflag = 0 : modProgBar.InitProgressBar(“Exporting : “)

Do While Blah
runflag = runflag + 1 : modProgBar.StepProgressBar(runflag, Count)
Loop

modProgBar.EndProgressDialog()

Advertisements
Post a comment or leave a trackback: Trackback URL.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: