Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

diplay form during calculation (iteration)

Posted on 2002-07-07
5
Medium Priority
?
151 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 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

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…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

963 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