Solved

Softwares turning white when performing a loop.

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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Access 2016 VB code 9 115
How to create a duplicate finder Application 9 121
Visual Studio 2005 text editor 10 38
vbModal 12 52
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…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
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…

772 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