Results 1 to 18 of 18

Thread: Control of multiple VB 6.0 Applications

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2008
    Posts
    150

    Unhappy Control of multiple VB 6.0 Applications

    Is there an easy way to run/control multiple seperate keyboard/mouse controlled VB 6.0 applications ?

    App 1 gets data from hardware devices, writes a text file to the HD.
    App 2 needs to load/process this text file, then write an " answer " text file.
    App 3 needs to load the answer file, then sort the data, then transmit an array of 55 by 3 long int over to a microcontroller.


    And do this over and over and over with a variation 1 time per day for calibration. All LOW speed communication serial or USB.

    Where do I go to research this ?

  2. #2
    Addicted Member
    Join Date
    Oct 2006
    Location
    Chennai, India
    Posts
    198

    Re: Control of multiple VB 6.0 Applications

    You cant have the easy way to write the complex architecture.

    But what you are asking can be easily done with the threading concepts which will run on time as a windows service.
    Regards
    Srinivasan Baskaran
    India

  3. #3
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863

    Re: Control of multiple VB 6.0 Applications

    Why don't you let the windows task-scheduler run those applications one after the other?
    ..and if you have control over all those 3, why don't you put all calculations into one?
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

  4. #4
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: Control of multiple VB 6.0 Applications

    Quote Originally Posted by cheenu_vasan
    But what you are asking can be easily done with the threading concepts which will run on time as a windows service.
    Multithreading (if that's what you mean) is not natively supported by VB6.
    Creating Windows Service using VB6 isn't an easy task either.

    As suggested using windows task scheduler could be best approach.

  5. #5
    Lively Member
    Join Date
    Jul 2007
    Posts
    98

    Re: Control of multiple VB 6.0 Applications

    Do you own the source of the applications?

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Jan 2008
    Posts
    150

    Smile Re: Control of multiple VB 6.0 Applications

    I do own the source of the applications. Each is a standalone VB application, and if I was sitting there running they keyboard (QUICKLY) with my hands, I could accomplish this task...

    Problem is I need to run it without me sitting there...

    In addition, we have the normal run:
    1. App1 generates file1.txt
    2. App2 reads that file, makes calculations, writes file2.txt
    3. App3 reads file2.txt, makes more calculations, then transmits data to a microcontroller.

    1 time per day the Cal run:
    1. App1 performs calibration, generates Cal.txt data file
    2. App2 reads that file, makes different calculations, writes calfile2.txt
    3. App3 reads calfile2.txt, makes more calculations, then transmits data to a
    microcontroller.

    I've heard you can do this with VB Scripts ?

  7. #7
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: Control of multiple VB 6.0 Applications

    Since none of these is a closed-source 3rd party program I'm not sure why you don't just combine them into one program. It sounds as if the way they are one or more of these needs manual input, i.e. you don't just run them one at a time by double-clicking their EXE icons, you have to do some other clicks or even type in some information.


    If they don't require additional manual input you could just create a batch file or a WSH script to run them in sequence.


    If they do need some input (directories to process, some parameters, etc.) they might be rewritten to run both as batch and interactive programs. Change them to start in Sub Main() in a startup BAS module. Check the Command$() function and if empty go ahead and load the present startup Form. If Command$() is not empty, parse out the necessary parameters.

    You'll want to go through your Forms and factor out all of the non-UI "work" into routines in BAS or CLS modules. The Sub Main() can then call these to do the work when it has command line parameters. You may find that when run in batch mode the programs should append relevant information to a log file of some sort. This should include any trapped errors, etc.

    This makes it easy to write a batch file to run them in the proper sequence. The batch file could be scheduled too then if appropriate.

  8. #8
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: Control of multiple VB 6.0 Applications

    Quote Originally Posted by prginocx
    Is there an easy way to run/control multiple seperate keyboard/mouse controlled VB 6.0 applications ?

    App 1 gets data from hardware devices, writes a text file to the HD.
    App 2 needs to load/process this text file, then write an " answer " text file.
    App 3 needs to load the answer file, then sort the data, then transmit an array of 55 by 3 long int over to a microcontroller.


    And do this over and over and over with a variation 1 time per day for calibration. All LOW speed communication serial or USB.

    Where do I go to research this ?
    In your opening post you ask is there an easy way to run/control multiple seperate keyboard/mouse controlled VB 6.0 applications and in your last post you stated if I was sitting there running they keyboard (QUICKLY) with my hands, I could accomplish this task so if you are not sitting there then why do you need them to run and have control over the keyboard and mouse? If you're not there then who is controlling the keyboard and mouse?

    Why not run App1, when it's done with it's thing it launches App2 and closes out, when App2 is done with it's thing it launches App3 and closes out, when App3 is done it closes out. The next day it starts all over again.
    Last edited by jmsrickland; Jan 30th, 2008 at 06:29 PM.

  9. #9
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: Control of multiple VB 6.0 Applications

    I should add here that even if your program(s) have to use a control (Winsock, MSComm, etc.) that must be sited on a Form, a batch or command-line VB program can always Load but not Show the Form.

    This may make it easier, since you do not have to move the "work" logic out of your Form modules. You just need to make sure it is factored out of your user interface event handlers into separate Subs and Functions.

  10. #10
    Lively Member
    Join Date
    Jul 2007
    Posts
    98

    Re: Control of multiple VB 6.0 Applications

    you have two solutions:
    1. redesign the 3 Apps you want to automate so that as dilettante said they get there params from the command line, or a separate .txt file(this case you should add some code in Apps 1 and 2 to store the output params in the file). Then write a fourth app that manages the tree apps. This solution is fast and requires almost no effort to write, but it is not a good way to solve the problem.
    2. Create one app that does all the tasks. This requires more work, but since you have the code of the other apps, and it works fine, just rearrange it(copy paste). I prefer this solution since it allows you avoid using and working with more than one VB project at a time.

    As said above if your parameters are static(the input is almost the same every day). You can save it to a file, that is opened from your "Control App". You may add a scheduling and some algorithms to generate the input params(if possible for the process you describe).

    Since you communicate with a hardware devices the second solution is better, because you will handle easier the time for communication with the devices. Otherwise, you "Control App" should :
    1. read/enter the input data (cfg, params, etc)
    2. load it in the SubApp 1
    3. Start timer that checks if SubApp 1 has finished (Cal.txt is generated and its path is stored in common file)
    4. When SubApp 1 has finished get the file path and stop the timer
    5. load it in the SubApp 2
    6. Start timer that checks if SubApp 2 has finished (Cal.txt is processed and calfile2.txt is generated. Its path(calfile2.txt) is stored in the common file)
    7. When SubApp 2 has finished get the file path and stop the timer
    8. load it in the SubApp 3
    9. Start timer that checks if SubApp 3 has finished (Process is finished, Confirmation flag is stored in the common file)
    10. When SubApp 3 has finished stop the timer
    11. Since you automate the process it is a "good programming" to write a record in a log file:
    Date started,
    Date ended
    paramsfile path(important to add, you must have track of the start state of the system)
    Status - Success/Error (it is good to add an error log file, that will store all generated errors)

    , and copy all the data generated (Cal.txt, calfile2.txt, may be a file log generated from SubApp3 before sending it to the device) in a folder with the current date.

    Since timers are used add a timeout parameter to avoid endless waiting at positions 3, 6, 9

    The algorithm gilts for both solution 1 and 2 with small changes(timers handling, I/O model).
    I would not recommend VBScript. Use ordinary VB, and yes VB is the language you must use it is simple and readable.
    In case of solution 1 (if input between apps is so simple as you describe it) the whole thing will take you 1-2 days may be one more if decide to add some features, such as log browser, Scheduler an so on...
    Last edited by tatkosmurff; Jan 31st, 2008 at 07:46 AM.

  11. #11
    VB Addict Pradeep1210's Avatar
    Join Date
    Apr 2004
    Location
    Inside the CPU...
    Posts
    6,614

    Re: Control of multiple VB 6.0 Applications

    I think the solution is pretty simple as this is not a multithreading/multiprocessing issue. You don't need to run 2 or more processes simultaneously, but just one after the other.

    All you need to do is just create a batch file and write the commands to execute these exe files one after the other. Then execute this batch file only whenever you want to get the work done.

    The other solution is to create a 4th application that does what you want:
    Shell the first exe and wait for it to close, then do the same with 2nd and 3rd exe. (If you search the forums you will find many examples of how to launch your application and wait until it returns.)

    Either way you go, you should provide method for your applications to close automatically (maybe thru a commandline parameter etc.)

    Pradeep
    Pradeep, Microsoft MVP (Visual Basic)
    Please appreciate posts that have helped you by clicking icon on the left of the post.
    "A problem well stated is a problem half solved." — Charles F. Kettering

    Read articles on My Blog101 LINQ SamplesJSON ValidatorXML Schema Validator"How Do I" videos on MSDNVB.NET and C# ComparisonGood Coding PracticesVBForums Reputation SaverString EnumSuper Simple Tetris Game


    (2010-2013)
    NB: I do not answer coding questions via PM. If you want my help, then make a post and PM me it's link. If I can help, trust me I will...

  12. #12

    Thread Starter
    Addicted Member
    Join Date
    Jan 2008
    Posts
    150

    Re: Control of multiple VB 6.0 Applications

    First of all, let me apologise, I am new to VB 6.0....I come from the world of electronics and LabView and PLC programming ( Shudder ). I didn't give enough information in my first post...

    App3, which communicates with the microcontroller, receives the command that starts either the Cal run OR the Data Acquisition Run. It also needs to know if those runs ( fail/pass which at this time is simply a text box nasty message.

    I could run all three apps from the keyboard, 'cause i can see the message in App3 text box saying " Start normal run OR start cal run ". App1 run takes from 15 min up to 4 hours. App2 process takes about 2 minutes always...App3 runs as fast as you can hit the keys.

    A typical sequence of events would be:
    App3 displays Run Normal,
    I Goto App1 and press Start Normal Run btn.
    When App1 writes the data.txt file, I go to App2 and load
    that file, it processes it and writes a result.txt file. I
    Go to App3 and load that result.txt file, it sends it to the Microcontroller.

    The cal run is almost the same as above.

    At this time there is no way for App1 or 2 to let the Microcontroller know there was an error.

    To combine all three apps together is the best solution, But App2 is the real barrier there...It was written over a period of 10 years by 3 different programmers, I think parts of it were even written in earlier versions of VB. Plus it calls huge libraries of FORTRAN AND c++ .dllS. The other two applications are fairly small, like you could create them in 3 months or so...

    It sounds like this " shell " idea is the way to go...Is there some book I could buy, or just scan the archives of this forum.

  13. #13

    Thread Starter
    Addicted Member
    Join Date
    Jan 2008
    Posts
    150

    Re: Control of multiple VB 6.0 Applications

    It sounds like this " shell " idea is the way to go...Is there some book I could buy, or just scan the archives of this forum.
    Last edited by prginocx; Jan 31st, 2008 at 02:49 PM.

  14. #14
    Lively Member
    Join Date
    Jul 2007
    Posts
    98

    Re: Control of multiple VB 6.0 Applications

    Yes shell will do, but as discussed above the real problem is how to load data automatically in your apps, since "shell" will only start you app, but not load any data, and/or make any decisions.

    Since you are new to VB try starting from the beginning(hope you have time)
    Install the IDE for VB6.0 and start using it. You can use the help provided in the MSDN 6.0(hope you got one). I think that since you have some programming experience it won't be so hard.

  15. #15
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: Control of multiple VB 6.0 Applications

    Shell will launch and load data if the app being loaded has a Command statement. Correct me if I am incorrect?

  16. #16

    Thread Starter
    Addicted Member
    Join Date
    Jan 2008
    Posts
    150

    Re: Control of multiple VB 6.0 Applications

    So " Shell " will only load an application ? I don't need to load them, I need to 'manipulate' them after they are loaded, like press keys/mouse click buttons...

    Not give them any data like numbers or strings, just press command buttons...Like if I was sitting there with just a mouse and my other arm was amputated.

  17. #17
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: Control of multiple VB 6.0 Applications

    I don't get it. You are confusing me.

    Post #16:

    I need to 'manipulate' them after they are loaded, like press keys/mouse click buttons...

    Post #6:

    Problem is I need to run it without me sitting there...

    You got me lost, prginocx

  18. #18

    Thread Starter
    Addicted Member
    Join Date
    Jan 2008
    Posts
    150

    Talking Re: Control of multiple VB 6.0 Applications

    I forgot the input to my eyes, which causes my mouse to click a command button. My eyes see the start msg on App3, which causes me to hit a command btn on App1.

    My eyes also see error messages ( 11 total ) posted in text boxes on App1 and 2 which I press command buttons on App3 to transmit to the controller.

    Error msg:
    1. Can't start run ( app 1 )
    2. Run in progress ( app 1 )
    3. Run finished ( app 1 )
    4. Can't autoload data file ( app 2 )
    5. Data Process Done ( app 2 )
    6. Can't start Cal run ( App1 )
    7.....etc...etc...

    So in addition to the btn presses needed for app1, 2, and 3...My eyes also read the txt msgs ( all standardized ) to run the three apps which tell me what buttons to press...
    So I can run all three apps together and from the POV of the Microcontroller, it thinks the Data acquisition system is automatic as long as I'm sitting there in front of the PC with all three apps running continuously...

    We actually had an intern run like this for almost a whole day (22hours)...Free beer supplied at the end of the run ( Gathering test data...)

    I will tell them to find an intern who is an amputee, just to make sure !!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width