This documentation is archived and is not being maintained.

Application will terminate when Sub Main() finishes

Visual Studio .NET 2003

In Visual Basic 6.0, an application would terminate only after every object that has been created was destroyed. Many applications set the startup object to Sub_Main in order to execute initialization code.

In Visual Basic .NET, the application terminates when the startup object is destroyed. If Sub_Main is set as the startup object, the application will terminate immediately after running the code in Sub_Main.

What to do next

  • Set a form to be the startup object.
  • Either move the code from Sub_Main to the form's Load event, or call Sub_Main from the Load event.

See Also

Choosing the Startup Form in Your Windows Application