Solved

Softwares turning white when performing a loop.

Posted on 2004-09-08
4
144 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

747 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now