Results 1 to 7 of 7

Thread: Sub Main ?

  1. #1

    Thread Starter
    Addicted Member Tengkorak's Avatar
    Join Date
    Nov 2006
    Posts
    240

    Sub Main ?

    how solutions to the sub main that is in VB6.
    because there is no facility in VB.NET?

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Sub Main ?

    There's almost never a need to use a Sub Main. In a VB 2008 application, the Application Framework is enabled by default. It provides a Startup event, which you can handle to perform actions before the startup form is created. It also provides a Shutdown event, which you cam handle to perform actions after the last form has closed. There are various other events and functionality available too. If you explain what you're trying to achieve then we can explain the best way to achieve it.

    In the very few situations where you really need to create your own Sub Main, you need to disable the Application Framework first, which allows you to select a Startup Object instead of a Startup Form.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Addicted Member Tengkorak's Avatar
    Join Date
    Nov 2006
    Posts
    240

    Re: Sub Main ?

    I want the first time he read the sub Main running play.
    because in sub Main play is there some process that needs to be done.
    include: open database connection, call and other.


    Public Sub Main()
    Call OpenDatabase()
    Call APPConfig()
    frmLogin.ShowDialog()
    End Sub
    Last edited by Tengkorak; Mar 2nd, 2011 at 10:25 PM.

  4. #4
    PowerPoster Evil_Giraffe's Avatar
    Join Date
    Aug 2002
    Location
    Suffolk, UK
    Posts
    2,555

    Re: Sub Main ?

    Quote Originally Posted by jmcilhinney View Post
    It provides a Startup event, which you can handle to perform actions before the startup form is created
    I think jmclongname had that covered.

  5. #5

    Thread Starter
    Addicted Member Tengkorak's Avatar
    Join Date
    Nov 2006
    Posts
    240

    Re: Sub Main ?

    Can give me a way to do this?

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Sub Main ?

    Quote Originally Posted by Tengkorak View Post
    Can give me a way to do this?
    If you read my previous post properly then already have it:
    [the application framework] provides a Startup event, which you can handle to perform actions before the startup form is created.
    Not that it would be hard to find others if you would care to search, but you can find an example by following the CodeBank link in my signature and checking out my WinForms Login thread.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  7. #7

    Thread Starter
    Addicted Member Tengkorak's Avatar
    Join Date
    Nov 2006
    Posts
    240

    Re: Sub Main ?

    thank you

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