Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 154
  • Last Modified:

diplay form during calculation (iteration)

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
themroc
Asked:
themroc
1 Solution
 
PaulHewsCommented:
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
 
wokaCommented:
You can also force a refresh of whatever you are trying to update. eg. txt_box.Refresh or frm_iterat.Refresh.
0
 
priya_pbkCommented:
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
 
PNJCommented:
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
 
themrocAuthor Commented:
PaulHews deEvents did the trick, although the other proposals are very good to consider, especialy the progress bar.

Thanks a lot
themroc
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now