Results 1 to 10 of 10

Thread: Unloading Startup Forms

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2002
    Posts
    8

    Unloading Startup Forms

    I have an application that starts with a login screen ... which passes the login values to a main form. How can I, after the values have been passed to the main form is loaded, unload the login screen without terminating the entire application?

    Thanks,
    JH

  2. #2
    Addicted Member
    Join Date
    Mar 2001
    Location
    Devon, UK
    Posts
    181
    me.close after you have past the values back
    Wind and waves resolves all problems.

  3. #3
    Addicted Member Sheppe's Avatar
    Join Date
    Sep 2002
    Location
    Kelowna, BC
    Posts
    245
    Originally posted by cim3
    me.close after you have past the values back
    I can't be sure, but I think that if you close the startup object, the rest of the application will:

    A) Close
    or
    B) Crash when you try to access other objects

    I think you'll need to use the Application.Run method. See help for all of its permutations.
    [vbcode]
    On Error Goto Hell
    [/vbcode]
    Sheppe Pharis, MCSD
    Check out http://www.vb-faq.com
    Click here for access to the free Code-Express source code and component sharing network for VB6
    Want a better way to skin your .NET applications? Click here!

  4. #4
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    then open the other form before closing the 1st one..lol

  5. #5
    Addicted Member Sheppe's Avatar
    Join Date
    Sep 2002
    Location
    Kelowna, BC
    Posts
    245
    Originally posted by PT Exorcist
    then open the other form before closing the 1st one..lol
    Have you used .NET? It's not like VB. If you unload the startup object, it does as I explained!
    [vbcode]
    On Error Goto Hell
    [/vbcode]
    Sheppe Pharis, MCSD
    Check out http://www.vb-faq.com
    Click here for access to the free Code-Express source code and component sharing network for VB6
    Want a better way to skin your .NET applications? Click here!

  6. #6
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    I believe your going to want to start your app with a main sub. Set it as the startup in the properties of the project. In that sub, you can load up the forms you will be using, and show them or unload them as you need. Once the main sub returns though, the application will end.

  7. #7
    New Member The Developer's Avatar
    Join Date
    Sep 2002
    Location
    London, England, UK
    Posts
    11
    I think the most sensible idea would be to set "Sub Main" as your application-entry point.

    From "Sub Main()" simple define a new login form object and then work your way from their. You'll notice that as long as any one form is loaded the application will NOT quit.

    So simply define a new Main Form and pass it the values from the login form. Now you can simple run the close method of the login form and you should hopefully still remain in your application on the main form. cool hey?

    See ya!
    The Developer

  8. #8
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    Nice recap of my post

  9. #9
    Addicted Member Sheppe's Avatar
    Join Date
    Sep 2002
    Location
    Kelowna, BC
    Posts
    245
    Have you guys even tried this, or are you guessing based on your experience with VB6- ? In my experience, unless you use Application.Run, even Sub Main will asynchronously load forms and then exit, or crash if you try to access an object, once it is done.
    [vbcode]
    On Error Goto Hell
    [/vbcode]
    Sheppe Pharis, MCSD
    Check out http://www.vb-faq.com
    Click here for access to the free Code-Express source code and component sharing network for VB6
    Want a better way to skin your .NET applications? Click here!

  10. #10
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    This works:
    Code:
    Public Class Class1
        Public Sub class1()
    
        End Sub
        Public Shared Sub Main()
            Dim cl As New Class1()
            cl.run()
        End Sub
    
        Private Sub run()
            Dim ftemp As New Form1()
            ftemp.ShowDialog()
        End Sub
    End Class
    Although, you have to show the form as showdialog not show.

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