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. Form Closing

Form Closing

Scheduled Pinned Locked Moved Visual Basic
helpquestion
9 Posts 5 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.
  • H Offline
    H Offline
    harveyhanson
    wrote on last edited by
    #1

    I am trying to use the following code to make sure all codes are closed when clicking the x in the top right hand corner. --- Private Sub frmTestTop_FormClosing(ByVal sender As Object, ByVal e As system.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing me.close End Sub --- It is however coming up with an dll stock overflow error, what am i doing wrong? Is there an easier way to do this??? Cheers

    M C M 3 Replies Last reply
    0
    • H harveyhanson

      I am trying to use the following code to make sure all codes are closed when clicking the x in the top right hand corner. --- Private Sub frmTestTop_FormClosing(ByVal sender As Object, ByVal e As system.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing me.close End Sub --- It is however coming up with an dll stock overflow error, what am i doing wrong? Is there an easier way to do this??? Cheers

      M Offline
      M Offline
      manni_n
      wrote on last edited by
      #2

      if u wanna close alll your forms, you can just put a close button on your form and code application.exit() or End in its clickin event .. thats it....

      H 1 Reply Last reply
      0
      • M manni_n

        if u wanna close alll your forms, you can just put a close button on your form and code application.exit() or End in its clickin event .. thats it....

        H Offline
        H Offline
        harveyhanson
        wrote on last edited by
        #3

        Its the close button in the control box, which when you click it just closes the current form, not any that may be hidden. Any ideas? Its in vb.net 2005 btw

        1 Reply Last reply
        0
        • H harveyhanson

          I am trying to use the following code to make sure all codes are closed when clicking the x in the top right hand corner. --- Private Sub frmTestTop_FormClosing(ByVal sender As Object, ByVal e As system.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing me.close End Sub --- It is however coming up with an dll stock overflow error, what am i doing wrong? Is there an easier way to do this??? Cheers

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          Application.Exit() ?

          Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

          J 1 Reply Last reply
          0
          • H harveyhanson

            I am trying to use the following code to make sure all codes are closed when clicking the x in the top right hand corner. --- Private Sub frmTestTop_FormClosing(ByVal sender As Object, ByVal e As system.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing me.close End Sub --- It is however coming up with an dll stock overflow error, what am i doing wrong? Is there an easier way to do this??? Cheers

            M Offline
            M Offline
            MatrixCoder
            wrote on last edited by
            #5

            The reason you are getting a Stack Overflow Error is because in your code, FormClosing allows you to perform last minute steps before the app shuts down. So when your app tries to close, you call Me.Close() which loops back and calls the same function continually. I hope that makes since.


            Trinity: Neo... nobody has ever done this before. Neo: That's why it's going to work.

            H 1 Reply Last reply
            0
            • M MatrixCoder

              The reason you are getting a Stack Overflow Error is because in your code, FormClosing allows you to perform last minute steps before the app shuts down. So when your app tries to close, you call Me.Close() which loops back and calls the same function continually. I hope that makes since.


              Trinity: Neo... nobody has ever done this before. Neo: That's why it's going to work.

              H Offline
              H Offline
              harveyhanson
              wrote on last edited by
              #6

              Yeah i get it. The reason i am trying to use it, is because the first form, i want to show another one and CLOSE the original form, however, when i close the first form, the whole program closes, so i had to hide it to get around this. Is there any way to get around this??? Sorry to bother you all, I'm just really stuck and its annoying!!

              M M 2 Replies Last reply
              0
              • H harveyhanson

                Yeah i get it. The reason i am trying to use it, is because the first form, i want to show another one and CLOSE the original form, however, when i close the first form, the whole program closes, so i had to hide it to get around this. Is there any way to get around this??? Sorry to bother you all, I'm just really stuck and its annoying!!

                M Offline
                M Offline
                MatrixCoder
                wrote on last edited by
                #7

                Well you can just hide the first form (Me.Hide()), and then when you want to close all the forms, use Application.Exit().


                Trinity: Neo... nobody has ever done this before. Neo: That's why it's going to work.

                1 Reply Last reply
                0
                • H harveyhanson

                  Yeah i get it. The reason i am trying to use it, is because the first form, i want to show another one and CLOSE the original form, however, when i close the first form, the whole program closes, so i had to hide it to get around this. Is there any way to get around this??? Sorry to bother you all, I'm just really stuck and its annoying!!

                  M Offline
                  M Offline
                  manni_n
                  wrote on last edited by
                  #8

                  well i think if first form is hidden by using me.hide(), then u wont be able to close it through form2(or your most active form)using that cross button in controll box. and even if you could then why to increase complexity. jst hide yr form one and close yr succesive forms by me.close and appliction.exit on the last form will be the easiest way... try it out...

                  1 Reply Last reply
                  0
                  • C Christian Graus

                    Application.Exit() ?

                    Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

                    J Offline
                    J Offline
                    Johan Hakkesteegt
                    wrote on last edited by
                    #9

                    I hadn't ever heard of that one either, but it really exists... :omg:

                    My advice is free, and you may get what you paid for.

                    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