[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 214
  • Last Modified:

Migrating To .Net - Loading Form From Sub Main Question

I'm starting a new project and am just now migrating to VB.NET - I generally set the start up object in my applications to 'sub main', then after initial startup tasks, load the main form.  When I do this in .Net the form loads, but is immediatly unloaded - I assume it's unloaded immediately after sub main is excited...  How can I show a form from 'sub main' without it being unloaded?  Example code:

Module moduleMain
    Public fMain As frmMain
    Public Sub main()

        fMain = New frmMain
        fMain.Show()

    End Sub
End Module
0
grafixnetwork
Asked:
grafixnetwork
  • 2
1 Solution
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
Use Application.Run() from Main():

Module moduleMain
    Public fMain As frmMain
    Public Sub main()

        fMain = New frmMain
        fMain.Show()

        Application.Run(fMain)  '                 <------------------------

    End Sub
End Module
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
You can also just do:

Module moduleMain

    Public Sub main()

        Application.Run(New frmMain)

    End Sub

End Module
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now