I am new to VB.NET, coming from VB6. Why does my application quit after loading a form from Sub Main?
Form loading is different in VB6 and .NET, whether VB.NET or C#. In NET, forms are not loaded directly as they were in VB6. Rather, you must create an instance of the form and then use the Show method of the form object. Many people, new to .NET, do the following in Sub Main, which worked in VB6, but not in VB.NET.
| Module Module1 Public Sub Main() Dim frm As New Form1 frm.Show() End Sub End Module |
| Module Module1 Public Sub Main() Dim frm As New Form1 frm.ShowDialog() End Sub End Module |
| Module Module1 Public Sub Main() Dim frm As New Form1 Application.Run(frm) End Sub End Module |