Starting from Sub Main()

BlackStone

Well-known member
Joined
Jun 14, 2004
Messages
75
I am a VB6 programmer who is trying to make the move to VB .NET. I have a question. In VB6, you could have a start your app from Sub Main() and then launch a form, or an instance of it.
Code:
Sub Main()
     Dim frm as Form1
     frm = New Form1
     Load frm: frm.Show
End Sub
This would automatically start the form when the app starts.

In VB.NET, I am doing a similar thing:

Code:
Module Startup
     Sub Main()
          Dim frm as New Form1
          frm.show()
     End Sub
End Module
I would think that the form would stay open even when the program leaves Main(), but it doesnt. The only way I could keep it open was to use .ShowDialog.
How can I do the .NET equivilent of my VB6 Sub Main()??
 
Set The Entry Point For The Project

If you open the Solution Explorer in VB.NET, then right mouse click upon the Project Name, and select properties.

From the Project Properties window select the Startup Object pulldown menu and then select the form use wish to execute when the Project starts, this does away with writing code to start the form and the form will remain open.

Hope this helps.

Jon.
 
Back
Top