Results 1 to 5 of 5

Thread: [RESOLVED] closing two form

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2002
    Location
    Philippines
    Posts
    877

    Resolved [RESOLVED] closing two form

    how to close a 2 two form?

    ex.

    VB Code:
    1. Form Load()
    2. Form2.show
    3. End

    when the form1 is closed i want also the form2 to be closed?

  2. #2
    Hyperactive Member
    Join Date
    May 2005
    Posts
    431

    Re: closing two form

    VB Code:
    1. Private Sub Form_Unload(Cancel As Integer)
    2.     End
    3. End Sub

    When ever you close form1, it will end your whole application and another form you have open.

  3. #3
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: closing two form

    ahh never use "END" !!!! Use "Unload Me". Ask MartinLiss why, i forgot
    My usual boring signature: Something

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2002
    Location
    Philippines
    Posts
    877

    Re: closing two form

    Quote Originally Posted by Zeratulsdomain
    VB Code:
    1. Private Sub Form_Unload(Cancel As Integer)
    2.     End
    3. End Sub

    When ever you close form1, it will end your whole application and another form you have open.
    ohh i didnt try that

    thank you

    br

  5. #5
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: [RESOLVED] closing two form

    as dclamp said, don't use End - all objects / connections / etc must be properly set to Nothing / Closed / Unloaded / etc

    if you want them to both unload when either one closes then it's as simple as doing:
    VB Code:
    1. ' In Form1
    2. Private Sub Form_Unload(Cancel As Integer)
    3.     Unload Form2
    4. End Sub
    5.  
    6. ' In Form2
    7. Private Sub Form_Unload(Cancel As Integer)
    8.     Unload Form1
    9. End Sub

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