Forum Moderators: open

Message Too Old, No Replies

Visual Basic 6 User Form Question

         

seanbun

7:05 am on Apr 12, 2006 (gmt 0)

10+ Year Member



Hi,

I wrote a small program and extract some text from heaps of files in a particular folder. I developed a progressbar on a seperated form to indicate the status of the execution.

Here is part of my code :

Static max As Integer
max = 250 'total width of the progress bar

Dim progress As Single
progress = (pointer / total) * max

Me.Label1 = "Extracting Email Address ... (" & pointer & " of " & total & ")"
Me.Label_Progressbar.Width = CInt(progress)
Me.Repaint

When i run the code, everything is fine and the car is progressing but the form is frozen. All buttons on this form become unclickable.

Is this a threading problem? Do you have any clue to fix this issue?

Thank you very much

Sean

Iguana

3:19 pm on Apr 12, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You obviously have an outer loop that does the processing. While that processing happens then everything will be frozen unless you say otherwise.

One solution is to introduce a DoEvents into the loop

Do While dadada
'process
'update progress bar
DoEvents
Loop

DoEvents are to be used sparingly - they allow repaints ets to happen but it also means buttons can be pressed - including the button that the user pressed in the first place to start this processing. You will probably have to disable at least one button and re-enable it later

seanbun

11:41 pm on Apr 12, 2006 (gmt 0)

10+ Year Member



Excellent ... Thank you very much for your help