Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I write a VB prog to execute w/o a form

Status
Not open for further replies.

Santor

Technical User
Dec 2, 2002
22
US
All the books and tutorials always show you how to write a program starting from a form. I want to write an EXE that runs just by double clicking a desktop shortcut to it, without any forms at all. What must I do to accomplish this?
I'm using VB.Net by the way.

John
 
dont know about in .net but i guess its the same....

set the forms visible property to false.

 
Thanks
I'm still just learning so bear with my stupid questions.
What code should be in this invisible form to run my program code which I currently have in a module?

John
 
(not sure about .net but for all previous ver. vb)

Insert a Sub Main() procedure into a module (with whatever code you want to execute) and set the startup object to sub main (found in project properties, general page)
 
Dont worry we were all learners at one stage!

without looking at your code i cant be to specific.

in the form_load event you could put a call to your sub in the module,

you will need some way of unloading your form as well (allthough it will close when you shut down your pc)

check out this thread if you need info on a forms life

thread222_343200
 
Not necessarily being applicable to .NET, but in VB6, you don't even have to have a form.

Create a new project
Add a module to the project
Create a Sub Main routine in the project
Start your processes from within the Sub Main
In Project->Properties, set the Start Up module to Sub Main
Remove the default Form from the project
Compile, and off you go.
Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Yup, that's what I did in VB6, delete the form, Sub Main in module and so forth. But when I try this in .Net it says it can't find a "Valid Sub Main()" and to add it to the class declaration. How do I do this?

John
 
That may be a question best asked in the .Net forum.

forum796
Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
then just put it in the form onload event... and after all your code executes run an

unload me to end the program

just in case and to keep the form from flashing, make it as small as possible, position it off screen on the layout, and set visible to false.

-Rob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top