Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. open a form closing the opener

open a form closing the opener

Scheduled Pinned Locked Moved Visual Basic
helptutorialquestion
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    ecentinela
    wrote on last edited by
    #1

    I have 2 forms. When I click on a button of form 1 I want to open form 2 and close form1. The problem comes when form 2 closes when form 1 closes. One solution will be to define a class and define the forms in it and not in the form 1, but I don't know how to do it. Someone can help me to do this or give me another solution? Thank you

    R V 2 Replies Last reply
    0
    • E ecentinela

      I have 2 forms. When I click on a button of form 1 I want to open form 2 and close form1. The problem comes when form 2 closes when form 1 closes. One solution will be to define a class and define the forms in it and not in the form 1, but I don't know how to do it. Someone can help me to do this or give me another solution? Thank you

      R Offline
      R Offline
      Roy Heil
      wrote on last edited by
      #2

      Why are you trying to do this? Is there a form 0? If so, you can have form 1 send a message to form 0 to open form 2. If there is no form 0, then form 1 is the main form, and when it closes, the application closes. This is why form 2 closes, too. If you want app 1 to close, try making form 2 a separate app, and execute it from app 1. Roy.

      1 Reply Last reply
      0
      • E ecentinela

        I have 2 forms. When I click on a button of form 1 I want to open form 2 and close form1. The problem comes when form 2 closes when form 1 closes. One solution will be to define a class and define the forms in it and not in the form 1, but I don't know how to do it. Someone can help me to do this or give me another solution? Thank you

        V Offline
        V Offline
        vinji
        wrote on last edited by
        #3

        hi dear, i can help u out. create a module . in the module create a main function module a sub main() dim f as new form1 f.showDialog() end sub end module and procedd in the same way as u were doing . the onlu thing u need to change now is ur startup object . set the startup object of the project to sub main and not to any form (Vinit Jain)

        E 1 Reply Last reply
        0
        • V vinji

          hi dear, i can help u out. create a module . in the module create a main function module a sub main() dim f as new form1 f.showDialog() end sub end module and procedd in the same way as u were doing . the onlu thing u need to change now is ur startup object . set the startup object of the project to sub main and not to any form (Vinit Jain)

          E Offline
          E Offline
          ecentinela
          wrote on last edited by
          #4

          Thanks to both, but it doesn't work. In 2005 express edition I can't (or don't know) select "sub main" as the startup object.

          Roy Heil wrote:

          Why are you trying to do this?

          How you work with multiple forms then without using an mdi environement?

          V 1 Reply Last reply
          0
          • E ecentinela

            Thanks to both, but it doesn't work. In 2005 express edition I can't (or don't know) select "sub main" as the startup object.

            Roy Heil wrote:

            Why are you trying to do this?

            How you work with multiple forms then without using an mdi environement?

            V Offline
            V Offline
            vinji
            wrote on last edited by
            #5

            hi ok u r working on .net 2005 express edition. i told u the code that would work in .net 2003. for dot net 2005 u dont hv to wory at all . in the properties of the project u have to set the shutdown mode of the application to "when the last form closes" karan jain

            E 1 Reply Last reply
            0
            • V vinji

              hi ok u r working on .net 2005 express edition. i told u the code that would work in .net 2003. for dot net 2005 u dont hv to wory at all . in the properties of the project u have to set the shutdown mode of the application to "when the last form closes" karan jain

              E Offline
              E Offline
              ecentinela
              wrote on last edited by
              #6

              OK!! this works well!! There is any inconvenience doing this?

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups