Solved

Softwares turning white when performing a loop.

Posted on 2004-09-08
4
148 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

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!

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

739 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