Progressbar Running while a huge procedure is called.

I have a huge procedure which takes about 40 Seconds to complete. I want to show a progressbar looping from 1 to 100
till the procedure is done.
How can I do it?

object:
While huge procedure is running user sees the progress bar running.
 
Example would be great.

Here is the code which I am trying to run:
--------------------------------
Dim Ltime
Ltime = Timer()
  While Timer() - Ltime < 600000000
    DoEvents
    Call modHtmlSupport.startHtml
    If i = 100 Then
      i = 1
    Else
      i = i + 1
      ProgressBar1.Value = i
    End If
   Wend
------------------------------
masoudkAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

halapayaCommented:
If ur huge procedure once called, does not return till it ends, there is no good way to find at which point the procedure is at any given point of the time. so showing a progres bar very accuretly will be little hard.

if u can clarify what happense in the procedure sometimes some one might give a better solution
0
vbWayneCommented:
'use a progress bar
'make a standard app and add a picture box called Progress
'in the PublicSub DoProgress..rename the frmSaveApps to your form name
'cut and paste the code and run to see an example
'
'<<<<<<<  Put this in a bas module  >>>>>>>>
'replace frmTips with the name of your app form
'or name your form frmTips for this example

Option Explicit

'number of things to do ex..files to be backed up
Public intCounted#  
'
Public Sub DoProgress(Percent)
'
' Percent is % of graph
'
Dim Work As Integer
Dim Num As String
'
Work = Int(Abs(Percent))
If Work > 100 Then Work = 100
'
With frmSaveTips.Progress       '<<<   With application form
    .BackColor = vbWhite        '<<<   White background
    If Not .AutoRedraw Then     '<<<   picture in memory ?
    .AutoRedraw = True          '<<<   make one
    End If
   
    .Cls                        '<<<   clear picture in memory
    .ScaleWidth = 100           '<<<   new scalemodus
    .DrawMode = 10              '<<<   not XOR Pen Modus

    Num = Format$(Work, "###") + "% Completed"

    .CurrentX = 50 - .TextWidth(Num) / 2         '<<<  %age is Centered

    .CurrentY = (.ScaleHeight - .TextHeight(Num)) / 2

    frmSaveTips.Progress.ForeColor = vbBlack     '<<<  Black text
    frmSaveTips.Progress.Print Num               '<<<  print percent

    frmSaveTips.Progress.Line (0, 0)-(Work, .ScaleHeight), vbBlue, BF
    .Refresh          '<<<  show
End With
'
End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

'  <<<<<<<<<<<<   event code for form   >>>>>>>>>>>>>>>>>>>

Private Sub Command1_Click()

intcounted = 1000    'whatever..use 100o for this example

'copy the files to the destination directory & increment the count
'do your whatevers..copy files and increment after each file
'progress must be within your loop or whatever

Dim i
For i = 1 To 1000
   Call DoProgress(copied / intTotalCount * 100)   'progress bar set to 100
'
    Print "This is dumb!"
   
    copied = copied + 1    'increment for progress bar
 Next i

End Sub
0
rondeaujCommented:
just use a Doevents statement. If your code is looping to fast the CPU will never get a chance to paint the progressbar's change. To test this put a Doevents statement have you change the value of the progressbar. You will not want to keep it there just like that as it will slow down your computer. You will only want to doevents will every ten or so loops.
0
pear49Commented:
Put a timer control. Set the timer interval to a satisfactory value. Set the action of the timer to point to your procedure to update the progress bar.
0
VBGuruCommented:
Hope this answers your question


Dim lngMaxLmt As Long
Dim intCount As Integer
Dim intCounter As Integer
Dim lngTime As Long

intCount = 1                                            ' This value ranges from 1 to 30000
intCounter = 1                                          'This value ranges from  1 to 20000 ... So  20000 X 30000 = 600000000
lngMaxLmt = 600000000
ProgressBar1.Min = 1                                    'Set the progress bar range from 1 -- 20000. So every time intCounter value croses 20000 or more then progressbar's value is incremented by 1
ProgressBar1.Max = 20000

Dim Ltime
Ltime = Timer()
lngTime = Timer() - Ltime
While lngTime < 600000000
    DoEvents
    Call modHtmlSupport.startHtml                          'Do your processing
    If intCounter >= 20000 Then
      intCounter = 0
      intCount = intCount + 1
      lngTime = 20000 * intCount
      ProgressBar1.Value = intCount
    Else
      intCounter = Timer() - Ltime                          'Calucalate the current time
    End If
Wend
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.