how to close forms

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Stroumfs
    New Member
    • Mar 2007
    • 28

    how to close forms

    I created a form and i inserted a close button.

    I want to close this form and another form of the project when i clicked the button close.
    I typed the following but the outside form doesn't close.
    Private Sub btnClose_Click( ByVal sender As Object, ByVal e As System.EventArg s) Handles btnClose.Click
    Me.Close()
    frmTest.Close()
    End Sub

    can anyone help
  • vijaydiwakar
    Contributor
    • Feb 2007
    • 579

    #2
    Originally posted by Stroumfs
    I created a form and i inserted a close button.

    I want to close this form and another form of the project when i clicked the button close.
    I typed the following but the outside form doesn't close.
    Private Sub btnClose_Click( ByVal sender As Object, ByVal e As System.EventArg s) Handles btnClose.Click
    Me.Close()
    frmTest.Close()
    End Sub

    can anyone help
    this code is in the same form or it in \another form?

    Comment

    • Stroumfs
      New Member
      • Mar 2007
      • 28

      #3
      Originally posted by vijaydiwakar
      this code is in the same form or it in \another form?
      this code is in the same form. it closes with the me.close the form but i have the problem with the other form frmtest

      Comment

      • vijaydiwakar
        Contributor
        • Feb 2007
        • 579

        #4
        Originally posted by Stroumfs
        this code is in the same form. it closes with the me.close the form but i have the problem with the other form frmtest
        dear just revese the code close the other form first then close me
        try it
        Good Luck

        Comment

        • Stroumfs
          New Member
          • Mar 2007
          • 28

          #5
          i can close the form which have the button but i cant close the form which is outside.

          Comment

          • vijaydiwakar
            Contributor
            • Feb 2007
            • 579

            #6
            Originally posted by Stroumfs
            i can close the form which have the button but i cant close the form which is outside.
            what do u mean by outside?
            pls clear
            i've checked ur code and it require just a reversal order of execution

            Comment

            • Stroumfs
              New Member
              • Mar 2007
              • 28

              #7
              Originally posted by vijaydiwakar
              what do u mean by outside?
              pls clear
              i've checked ur code and it require just a reversal order of execution
              i reversed it but still is not working

              Comment

              • vijaydiwakar
                Contributor
                • Feb 2007
                • 579

                #8
                Originally posted by Stroumfs
                i reversed it but still is not working
                just check the code
                Code:
                Public Class Form1
                
                    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
                        Form2.Show()
                    End Sub
                
                    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
                        Form2.Close()
                        Me.Close()
                    End Sub
                End Class

                Comment

                • Stroumfs
                  New Member
                  • Mar 2007
                  • 28

                  #9
                  case close .thanks.

                  Comment

                  Working...