Results 1 to 3 of 3

Thread: sub main in vb.net, where are you

  1. #1

    Thread Starter
    Registered User jkw119's Avatar
    Join Date
    Oct 2001
    Location
    Pittsburgh
    Posts
    256

    sub main in vb.net, where are you

    i just started vb.net

    i made two forms and that is about it. All i want to know is how to create some main sub where you call the first form. Every time i hit play, the program just loads the first form i made. I tried adding a module and Sub Main like in vb 6 but that doesn't work...i am lost.

    jeff

  2. #2
    Addicted Member
    Join Date
    Nov 2000
    Location
    San Diego - California
    Posts
    251
    You add a module to the project. Then add a sub main to the module.

    'The program entry point
    Public Sub Main()
    Dim frmMain As New frm_main()

    Application.Run(frmMain) 'Continue
    End Sub


    NEXT - You need to set the Startup Object

    In the solution explorer - right click the project and select properties. Set the Startup object to sub main.

    Goodluck

  3. #3
    Tygur
    Guest
    Main() doesn't have to be in a module. You could just throw it in one of the forms:
    Code:
        Public Shared Sub Main()
            'Your code goes here
        End Sub
    Note that VB.NET will not automatically create an instance of the form for you once you put Sub Main in it. You will have to create it yourself.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width