Jump to content
Xtreme .Net Talk

Recommended Posts

  • *Experts*
Posted

Yes; Main is the only sub that executes on its own (on the starting

of the app). The only way to get any other subs to run is to call them

(directly or indirectly) through the Sub Main (In C#... in VB.NET, you

don't even need an Application.Run statement for the program to

start).

  • *Experts*
Posted

Is that sub in the same form that is set as your startup object?

Right click on the project in the solution explorer and click Properties.

There will be a "Startup Object" setting. Make sure it is set to the

same form that the Sub Main is located in.

  • *Experts*
Posted

Yes, but there should be two selections available:

"WindowsApplication2.Form1" and "WindowsApplication2.Form2"

 

If Sub Main is in Form1, you want the startup object to be the first one,

otherwise you want it to be the second one.

  • *Experts*
Posted

Oh, when you remove the Run command? You need the Run

command in the Sub Main of your startup object; sorry, I misread your

original statement.

 

If you take out the Run statement, then your program is never really

executing; it's simply starting the program, and closing it immediately

because there's nothing to do. When you use the Run command,

it starts a standard Windows message loop for the window, meaning

that the window becomes active, and recieves events and various

window messages that are sent to it. Without a message loop and

a thread to run it on, there is no program.

Posted
(In C#... in VB.NET, you

don't even need an Application.Run statement for the program to

start).

 

I tried removing that and also just writing Run(); but it never works without

 

Application.Run();

Is that the way it should be?

 

Also, I noticed in the properties window something about having more than one Main(). Is that possible?

C#

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...