Solved

diplay form during calculation (iteration)

Posted on 2002-07-07
5
148 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 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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Adding to a VBA? 6 93
Send outlook email from VBS Script 2 67
Error with a code discussed on this page 5 51
VB6 calling COM DLL written in Visual Studio 2003 6 58
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

752 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