Shared Sub Main

M

Miro

I am trying to follow the following example:

http://www.getdotnetcode.com/GdncStore/free/Articles/VB NET Sub Main Procedure.htm

on adding things to my own 'sub main'.

I created a form project and added Form1 and Form2 to the project.

Then in the project property's the startup form is setup as form1. ( i have
the option of Form1 or Form2 ).

How do I get rid of the options in the setup to have a startup form?, and
where to I setup the 'StartupForm' to hit the subMain() here.

When I go to the <MainForm>Form1</MainForm> of the Application.myapp file
and remove it, I get an error that no startup form has been specified.

My objective is to set form2 to be the startup form

Thanks,

Miro
 
F

Family Tree Mike

Miro said:
I am trying to follow the following example:

http://www.getdotnetcode.com/GdncStore/free/Articles/VB NET Sub Main Procedure.htm


on adding things to my own 'sub main'.

I created a form project and added Form1 and Form2 to the project.

Then in the project property's the startup form is setup as form1. ( i
have the option of Form1 or Form2 ).

How do I get rid of the options in the setup to have a startup form?,
and where to I setup the 'StartupForm' to hit the subMain() here.

When I go to the <MainForm>Form1</MainForm> of the Application.myapp
file and remove it, I get an error that no startup form has been specified.

My objective is to set form2 to be the startup form

Thanks,

Miro

Go to the project properties and at the application tab, uncheck "Enable
Application Framework". Now, "Sub Main" should be an option.

This is using VB 2008 Express, so your mileage may vary...
 
K

Kevin Provance

|I am trying to follow the following example:
|
|
http://www.getdotnetcode.com/GdncStore/free/Articles/VB NET Sub Main Procedure.htm
|
| on adding things to my own 'sub main'.
|
| I created a form project and added Form1 and Form2 to the project.
|
| Then in the project property's the startup form is setup as form1. ( i
have
| the option of Form1 or Form2 ).
|
| How do I get rid of the options in the setup to have a startup form?, and
| where to I setup the 'StartupForm' to hit the subMain() here.
|
| When I go to the <MainForm>Form1</MainForm> of the Application.myapp file
| and remove it, I get an error that no startup form has been specified.
|
| My objective is to set form2 to be the startup form

Click the Project menu item, select <projectname> Properties. On the
General Tab under Startup Object, select the form you want. Click OK.
 
M

Miro

Kevin,

Please read Family Tree Mikes' reply above, that is what I was looking for.

Cheers'
 
M

Miro

Thanks FamilyTreeMike, that worked.
I can now put a 'debugger' stop on my code and it works.

One side question,

If I have to Register a dll....

Do I have to put it into the "SUB MAIN", in which case I must uncheck "use
application framework" ?
Are there any big drawbacks to unchecking "use application framework"?

Thanks,

Miro
 
M

Miro

After clicking on the "View Application Events"...I think I found what I
wanted by registering the dll in the Startup

Private Sub MyApplication_Startup(ByVal sender As Object, ByVal e As
Microsoft.VisualBasic.ApplicationServices.StartupEventArgs) Handles
Me.Startup

Seems to work ok...

Miro
 
A

Alex Clark

Miro,

See inline replies:

Miro said:
Thanks FamilyTreeMike, that worked.
I can now put a 'debugger' stop on my code and it works.

One side question,

If I have to Register a dll....

Do I have to put it into the "SUB MAIN", in which case I must uncheck "use
application framework" ?

I wouldn't put it in any part of the application itself, I'd do it as part
of an installer process. Putting that code into the application is likely
to cause UAC prompts on Win Vista/7 as your app will need elevated rights to
perform that action. If you're talking about a utility for personal use
it's probably no big deal, but if you're talking about a corporate app or
something you're selling to desktop users, I wouldn't recommend it.
Are there any big drawbacks to unchecking "use application framework"?

Personally I never use it and have never missed any of the functionality; I
always prefer to take control from the exact entry point (i.e. Sub Main)
rather than assigning start up forms.

HTH,
Alex
 
M

Miro

What about using the application events and put it into the startup?
Or you are saying you would still just put it into the main form's Public
Sub New() just after the initialize component?
 
F

Family Tree Mike

Miro said:
What about using the application events and put it into the startup?
Or you are saying you would still just put it into the main form's
Public Sub New() just after the initialize component?

You probably should not be registering dlls (for COM, I presume), unless
you are writing a setup application. What is the scenario where you
want to register a dll at application startup?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top