Solved

One more question concerning GetModuleUsage

Posted on 1997-07-08
1
212 Views
Last Modified: 2008-03-06
Hi experts,

I have one more question concerning the "GetModuleUsage" API function.

With help of the "Shell" and "GetModuleUsage" (= API function)
command I want to start several times a math software which reads input from a text file and does some very time consuming calculations with this input data.

So far my source code has the following structure:

Private Sub btnEndCommand_Click()
Dim i%
For i = 0 To 3
result = Shell("my_math_program.exe " , 6)
While GetModuleUsage(result) > 0
DoEvents
Wend
Next
End Sub

This attempt unfortunately has one very big setback:

In my VB sample procedure the user has to stop and start INTERACTIVELY
the single my_math_program sessions.

Is it possible to use "GetModuleUsage" in a "non-interactive-mode", too?

I would like to let us say 3 calculations being done during the night while
I am sleeping.
So I don't want to get up after each session and finish/start each session
by mouse click.
I want that each calculation session is started and finished AUTOMATICALLY,
without my interaction. So the second call of my_math_program should be
done after the first calculation is finished, the third call should be done
after the second calculation is finished, and so on.
Unfortunately one doesn't know the needed time for each calculation before,
so it makes no sense to start the calulation sessions in a certain time
interval.

What else could I try, If "GetModulUsage" is not the appropriate idea to
solve my problem?

If it is a help for you experts, I can send you this math program. It is
freeware so it can be freely distributed.

Any suggestions are highly appreciated.

cu
Christian Mathes
0
Comment
Question by:mathes
1 Comment
 
LVL 2

Accepted Solution

by:
vorlon earned 50 total points
Comment Utility
mathes,
Is you're math program an interactive application? I'm assuming it is not since it can run at night. In order for you're vb program to run you're math program several times, you can do a few things:

A) Create a loop in which:
1) you're math program gets executed
2) you're vb program checks for its termination using GetModuleUsage
3) you're vb program does some processing after the math program is done
4) go back to step 1

B) Instead of creating a closed loop with the above steps, place the above steps in a timer. Have the timer go off, say, every 5 minutes. Each time the timer event goes off, you could check the time from the system clock and therefore run the formentioned loop at predeterined times. Since you don't know what time to process, then it's better to maybe run the process every 5 minutes anyway.

QUESTION: Since you don't know what time to process the results of the math program, how do you determine when it's time run the vb program? All is dependent on that. The GetModuleUsage function is only usefull in determining when a certain application has terminated.

If you have any further questions don't hesitate to comment...
Hope this helps.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
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…
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…
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…

772 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

13 Experts available now in Live!

Get 1:1 Help Now