Results 1 to 11 of 11

Thread: Closing Form**Resolved**

  1. #1

    Thread Starter
    Addicted Member VBGangsta's Avatar
    Join Date
    Aug 2003
    Location
    New York
    Posts
    219

    Question Closing Form**Resolved**

    Hi, I have it so a form loads from the sub main and after the user presses a button i want it to load a another form and close the current on. I can load it fine but i tried everything and cant close the current form. I dont want to hide it either. Thanks

    And is there a way to disable that JIT debugger from coming up?
    Last edited by VBGangsta; Dec 18th, 2003 at 05:13 PM.
    -Rob

  2. #2
    Frenzied Member
    Join Date
    Aug 2000
    Location
    Birmingham, AL
    Posts
    1,276
    You could do this:
    VB Code:
    1. Public Sub main()
    2.  
    3.         Dim frm1 As New Form1
    4.         Dim frm2 As New Form2
    5.  
    6.         frm1.ShowDialog()
    7.  
    8.         frm2.ShowDialog()
    9.  
    10.     End Sub
    and on the Form1 button click call Me.Close()

  3. #3

    Thread Starter
    Addicted Member VBGangsta's Avatar
    Join Date
    Aug 2003
    Location
    New York
    Posts
    219
    i tried to Me.Close() after the second form was loaded and it didnt work.
    -Rob

  4. #4
    Frenzied Member
    Join Date
    Aug 2000
    Location
    Birmingham, AL
    Posts
    1,276
    make sure the Startup Object is set to Sub Main...

    and you have to make your Sub Main is just like mine and call ShowDialog() not just Show() or it won't work.

  5. #5

    Thread Starter
    Addicted Member VBGangsta's Avatar
    Join Date
    Aug 2003
    Location
    New York
    Posts
    219
    On submain...
    VB Code:
    1. Module mMain
    2.  
    3.     Public Sub Main()
    4.                     If frmRegister.IsRegistered Then
    5.                 Dim frm As New Form4
    6.                 frm.ShowDialog()
    7.                 ''(what i had)'Application.Run(New Form4)
    8.             End If
    9.                     Application.Exit()
    10.         End If
    11.     End Sub
    12.  
    13. End Module

    On form4
    VB Code:
    1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    2.                 Me.Close()
    3.         Dim frm As New Form1
    4.         frm.ShowDialog()
    5.     End Sub
    I still have the same problem, am i doing something wrong?
    -Rob

  6. #6
    Addicted Member Rally2000's Avatar
    Join Date
    Dec 2003
    Location
    Central USA
    Posts
    134
    I have that exact same problem and also cant get it to work.

  7. #7
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Try this:
    VB Code:
    1. Module mMain
    2.  
    3.     Public Sub Main()
    4.            If frmRegister.IsRegistered Then
    5.                 Dim frm As New Form4
    6.                 frm.ShowDialog()
    7.                 Dim frm1 As New Form1
    8.                 frm1.ShowDialog()
    9.             End If
    10.                     'Application.Exit() not needed
    11.     End Sub
    12.  
    13. End Module

  8. #8
    Frenzied Member
    Join Date
    Aug 2000
    Location
    Birmingham, AL
    Posts
    1,276
    The second form shows when the first form is closed too.

    I think he only wants the second form to show if the button is clicked.

  9. #9

    Thread Starter
    Addicted Member VBGangsta's Avatar
    Join Date
    Aug 2003
    Location
    New York
    Posts
    219
    Yeah, i want form1 to open only after a button on form4 is pressed.
    -Rob

  10. #10
    Frenzied Member
    Join Date
    Aug 2000
    Location
    Birmingham, AL
    Posts
    1,276
    VB Code:
    1. Module mMain
    2.  
    3. Public Sub Main()
    4.  
    5.     If frmRegister.IsRegistered Then
    6.  
    7.         Dim frm As New Form4
    8.  
    9.         frm.ShowDialog()
    10.  
    11.     End If
    12.  
    13. End Sub

    On form4
    VB Code:
    1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    2.  
    3.     Dim frm As New Form1
    4.  
    5.     Me.Hide()
    6.     Me.Close()
    7.     frm.ShowDialog()
    8.  
    9. End Sub

  11. #11

    Thread Starter
    Addicted Member VBGangsta's Avatar
    Join Date
    Aug 2003
    Location
    New York
    Posts
    219
    Excellent!!!! Thank you Much
    -Rob

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