Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

diplay form during calculation (iteration)

Posted on 2002-07-07
5
Medium Priority
?
150 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
[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
5 Comments
 
LVL 38

Accepted Solution

by:
PaulHews earned 240 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
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…
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…
Suggested Courses

721 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