[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 152
  • Last Modified:

Softwares turning white when performing a loop.

I created an application in vb. It contains a code that copies a file from one location to another location. When the software starts to copy the file the software turns white when performing the loop in windows xp only. But actually the software and the loop is performing well. After the loop is over the software interface returns back. This happens when some long loop is working in the software. When i try to click the software when it turns white, the caption of the window comes as not resonnding, but after it coes out of the loop everything turns normal. How to stop the software turning white. Please help me in this.

0
bijesh
Asked:
bijesh
  • 2
1 Solution
 
aelatikCommented:
In the loop put this line:

DoEvents
0
 
aelatikCommented:
IE :

For i = 1 to 1000
 'Your code
 Doevents
nexy
0
 
mmusanteCommented:
You can also add this to your loop ...

Me.Refresh

(If you use DoEvents you have to disable all your controls to avoid that the user can launch other scripts)
0
 
redfordbCommented:
You need to add the doevents command inside your loop as per aelatiks suggestion.
But instead of calling doevents on every iteration of your loop, you should limit it to only happen every x iterations. The higher x the less doevents will happen and the quicker your processing will happen. Although if you are updating a progress bar (or something to that effect), the updates will look blockier.

Example.

For i = 1 to 10000
       'Other Processing Goes here
        If i Mod 100 = 0 Then
                DoEvents
        End If
Next i
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now