Solved

diplay form during calculation (iteration)

Posted on 2002-07-07
5
144 Views
Last Modified: 2010-05-02
I wrote a application in VB 6.0. When I start a iteration which takes sevaeral seconds I would like to show a form
called "frm_iterat" which indicates that the application is still calculating. I also would like to show the change of the the calculated values in a txt_box of annother form after each loop through. Unfortuately apparently there is not anought time inbetween each run to display the changed values. And the form frm_iterat is not displayed correctely.
What do I have to do???????
0
Comment
Question by:themroc
5 Comments
 
LVL 38

Accepted Solution

by:
PaulHews earned 60 total points
ID: 7135692
Put a DoEvents statement in the loop that is processing the data.  This will allow your form to display and update of controls to take place.
0
 
LVL 2

Expert Comment

by:woka
ID: 7136238
You can also force a refresh of whatever you are trying to update. eg. txt_box.Refresh or frm_iterat.Refresh.
0
 
LVL 2

Expert Comment

by:priya_pbk
ID: 7137007
You can try using the sleep API

'Declare this
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

And in the code where you are iterating, use it this way:

For i=1 to 150000
  'Your code goes here
  sleep(2000) 'sleeps for 2 second
Next

----------------------------------
Maybe you can use a "Progress Bar" in your application. This is also a neat way of displaying the level of process done so far and looks quite professional.

Hope this helps!

-priya

0
 
LVL 3

Expert Comment

by:PNJ
ID: 7137476
Sometimes using "DoEvents" each pass slows down the application too much. A "neat trick" is to do something like:

   Dim ACounter as Long
   If ACounter Mod 100 Then DoEvents
   ACounter = ACounter + 1

This way the screen/form/controls refresh but you only refresh every 100 (or whatever). I agree with Priya, the common control "ProgessBar" does give a nice look to an application.
0
 

Author Comment

by:themroc
ID: 7137789
PaulHews deEvents did the trick, although the other proposals are very good to consider, especialy the progress bar.

Thanks a lot
themroc
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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…
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…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

911 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

20 Experts available now in Live!

Get 1:1 Help Now