Solved

Softwares turning white when performing a loop.

Posted on 2004-09-08
4
147 Views
Last Modified: 2010-05-18
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
Comment
Question by:bijesh
  • 2
4 Comments
 
LVL 14

Expert Comment

by:aelatik
ID: 12013545
In the loop put this line:

DoEvents
0
 
LVL 14

Expert Comment

by:aelatik
ID: 12013547
IE :

For i = 1 to 1000
 'Your code
 Doevents
nexy
0
 
LVL 6

Expert Comment

by:mmusante
ID: 12013853
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
 
LVL 3

Accepted Solution

by:
redfordb earned 125 total points
ID: 12013909
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question