Results 1 to 4 of 4

Thread: close form2 from form1

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2002
    Posts
    352

    close form2 from form1

    I have the following code in a command button in form1:
    Code:
            Dim frm As New Form2()
            frm.Close()
    How can i close form2 using a command button on form1?

  2. #2
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    You can't, unless you have access to an instance of it.
    Is form2 loaded by form1?
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2002
    Posts
    352
    yes, i believe in the form1.load, i have a form2.show()

  4. #4
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    If I didn't get it wrongly then do this :

    declare a variable in the general declaration of Form1
    VB Code:
    1. Dim frm2 As New Form2()
    2.  
    3.     Private Sub show_form2_Click(ByVal sender As System.Object,_
    4.  ByVal e As System.EventArgs) Handles show_form2.Click
    5.         frm2.Show()
    6.     End Sub
    7.  
    8.     Private Sub close_form2_Click(ByVal sender As System.Object,_
    9.  ByVal e As System.EventArgs) Handles close_form2.Click
    10.         frm2.Close()
    11.     End Sub
    dunno if you mean that ???

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