General discussion

Locked

VB 6: Console/Batch module

By MWEST ·
I'm relatively new to VB and don't know how to create a "console/batch" application that will run without any graphical user interface. Other languages call this a console app. I don't find this term in any of my VB help books. Basically, I want to create an application using VB 6 that when executed will run from start to finish with no user involvement and no forms being shown. Is there a keyword (similar to console) that I should be looking for that will show me how?

This conversation is currently closed to new comments.

5 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

VB 6: Console/Batch module

by iainsheppard In reply to VB 6: Console/Batch modul ...

Check out this knowledge base article:

http://support.microsoft.com/default.aspx?scid=kb;en-us;171654 (Q171654)

You could probably alter this to suit your needs - the main thing to do is move the code from the Form_Load sub to your own main()sub maybe.

Collapse -

VB 6: Console/Batch module

by MWEST In reply to VB 6: Console/Batch modul ...

Poster rated this answer

Collapse -

VB 6: Console/Batch module

by MadestroITSolutions In reply to VB 6: Console/Batch modul ...

To make an application that runs without user intervention or forms:

- Make a new standard project
- Remove the form that is placed there by default
- Add an empty Module
- Create a Sub Main in the module
- Set the project Startup object to "Sub Main", by going to Menu Project > Project1 Properties
- Check the "Unattended Execution" box (optional, will send any messages or actions that result in user interaction to an event log)
-------------------------------------------

Here is anexample of the sub Main:

Private Sub Main()

'Do whatever you want to to here

End Sub

Once you compile it, run your program and you will see that no interaction happens, it just executes on the background.

You may want to pass arguments to it. Any arguments passed to your program trhough the command line (E.g. cmdPrg.exe file01.dat) are stored in a system variable called "Command", so if you want to retrieve it, get the value of this variable.
E.g:

Dim Parameter as string
Parameter = Command


If you want to debug the program with command line arguments, set the argument value in the box called "Command line arguments" located in Project > Project1 Properties > Tab Make.

Thats all there is to it. If you have any problem, don't hesitate to write at:
juanr@akaconsulting.com

Good Luck!

Collapse -

VB 6: Console/Batch module

by MWEST In reply to VB 6: Console/Batch modul ...

Thanks. I basically did what you suggested (created a new module named Main within the current project and then copied all of my logic into it). Then deleted the form and ran, and all went well. THanks.

Collapse -

VB 6: Console/Batch module

by MWEST In reply to VB 6: Console/Batch modul ...

This question was closed by the author

Back to Web Development Forum
5 total posts (Page 1 of 1)  

Related Discussions

Related Forums