Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Keana Schmidt   on Oct 20 In MS Office Category.

  
Question Answered By: Joann Gardner   on Oct 20

So, it helps to not work from memory. Here are the last details and a couple
corrections:
- Another label is required on the form called lblProgress. Set this label
to 0 pixels wide, Left at 6 pixels, background color set to Highlight
- Set the Form's width to 304.5 pixels

Use the following code:
'********************************************************
Sub TestProgress()

Dim I As Integer
Dim intLimit As Integer

frmProgress.Show
intLimit = 10000
For I = 1 To intLimit
ShowProgress I, intLimit, "Processing item " & _
CStr(I) & " of " & CStr(intLimit)
Next I
frmProgress.Hide

End Sub
'**********************************************************
Sub ShowProgress(ByVal snglFileCounter, ByVal snglCount, _
ByVal strFolderPath As String)

Dim snglDecimal As Single
Dim snglWidth As Single
Dim strLabelText As String

If BoolCancel Then Exit Sub

snglDecimal = snglFileCounter / snglCount
snglWidth = snglDecimal * 280
strLabelText = strFolderPath
frmProgress.lblPercent.Caption = strFolderPath
frmProgress.lblStatus.Caption = snglCount & _
" Items in " & strLabelText
frmProgress.lblProgress.Width = snglWidth
frmProgress.Repaint

End Sub
'*********************************************************

The idea is to have a small label with a distinct background color. Each
time you call the routine, you're giving values from which a percentage is
calculated and lblProgress, with its dsitinctive color, is made wider to
correspond with your progress from 0 to 100%. The percentage calculation is
exactly what we were taught in school - to get the percentage of elements
from a big pile of elements, divide the number of the item you're working
with and divide by the total number of elements. That percentage is then
multiplied by the maximum width of lblProgress (280) to determine just how
many pixels wide lblProgress should be if we're only at, say, 49%.

Use this code in frmProgress itself:
Private Sub cmdCancel_Click()

BoolCancel = True
Me.Hide
Unload Me
Exit Sub

End Sub

Share: 

 

This Question has 6 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on Userform ( .Repaint ) ? Or get search suggestion and latest updates.


Tagged: