Results 1 to 7 of 7

Thread: how to close a form correctly

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2013
    Posts
    95

    how to close a form correctly

    Code:
    Public Class frmDataInput1
        
        Private Sub frmDataInput1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    
            'Display Form Title
            Me.Text = "Hasselburg Tie " & frmStartUp.CmbTieSize.Text & " Data Input"
    
            'Closes Form Startup
            frmStartUp.Close()
        End Sub
    End Class
    The first User form that appears is Start up form. This is where the user picks the product type. Depending on the product type selected, will determine the user form that opens next. In this case, form Data Input 1 opens. What I need to see happen is that when the user selects the product from the start up and opens the designated form it should then close the Start up form and leave open the frmDataInput1. However, that does not occur. When I select the product that would use this form it opens it up and closes it when the form start up closes. But if I change frmStartUp.Close() to frmStartUp.Hide() , it then does what I want it to do. I don't want to have more than one form open in memory. Is there a way to fix this? thanks

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    25,481

    Re: how to close a form correctly

    in your vb menus:

    Project-->Properties-->Shutdown Mode-->When last form closes

  3. #3
    Fanatic Member
    Join Date
    Nov 2010
    Posts
    965

    Re: how to close a form correctly

    Its little difficult to understand what you are trying to achieve.
    But Do you want that when the user select the product so the desired form will open and the current form closes? is it what you want?

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Feb 2013
    Posts
    95

    Re: how to close a form correctly

    The first form that appears is the startup form. Once the user selects the product from that startup userform. The startup form closes and opens the form that corresponds to the selected product. I am running visual studio 2012. .Paul, when I went to my program's properties, I did not seem anything in regards to Shutdown mode. Thanks to both of you for your help.

  5. #5

  6. #6
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    25,481

    Re: how to close a form correctly

    sorry, try:

    Project-->Properties-->Application-->Shutdown Mode-->When last form closes

    it's definitely there (I checked all versions from 2008-13)...

    Name:  02-10-2014_05.14.47.jpg
Views: 199
Size:  31.8 KB

  7. #7
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    25,481

    Re: how to close a form correctly

    also you need to open the new form before closing the first form. as 'when last form closes' implies, it will end the application as soon as there are no forms open

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