vb.net: Using a Button on a Form to open another form, doesn't work





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







2















I encounter the following scenarios when I try to use 2 forms. My workflow is as follows:



(1) Load Form1.



(2) A click on button1 on Form1 closes Form1 and opens Form2.



Solution A: If I use the following code:



Dim oForm As New Form2
oForm.ShowDialog()
Me.Close()


Then Form1 will be under Form2 (Form1 still opens).



Solution B: If I use the following code:



Dim oForm As New Form2
oForm.Show()
Me.Close()


Then Form1 closes and Form2 opens, but Form1 is not on the top layer.



I have looked through the solutions for this, most propose solution B, but for me, both solutions won't work the way I want. Can anybody tell me the reason?










share|improve this question

























  • Are you building a login dialogue?

    – Louis van Tonder
    Jul 2 '14 at 7:07











  • See my answer on a login scenario

    – Louis van Tonder
    Jul 2 '14 at 7:17






  • 1





    I feel like we are having to play 20 questions in order to find out essential information about what you are attempting. You need to put some effort in creating an example that will demonstrate your issue or post the code that you are using.

    – Mark Hall
    Jul 2 '14 at 16:16




















2















I encounter the following scenarios when I try to use 2 forms. My workflow is as follows:



(1) Load Form1.



(2) A click on button1 on Form1 closes Form1 and opens Form2.



Solution A: If I use the following code:



Dim oForm As New Form2
oForm.ShowDialog()
Me.Close()


Then Form1 will be under Form2 (Form1 still opens).



Solution B: If I use the following code:



Dim oForm As New Form2
oForm.Show()
Me.Close()


Then Form1 closes and Form2 opens, but Form1 is not on the top layer.



I have looked through the solutions for this, most propose solution B, but for me, both solutions won't work the way I want. Can anybody tell me the reason?










share|improve this question

























  • Are you building a login dialogue?

    – Louis van Tonder
    Jul 2 '14 at 7:07











  • See my answer on a login scenario

    – Louis van Tonder
    Jul 2 '14 at 7:17






  • 1





    I feel like we are having to play 20 questions in order to find out essential information about what you are attempting. You need to put some effort in creating an example that will demonstrate your issue or post the code that you are using.

    – Mark Hall
    Jul 2 '14 at 16:16
















2












2








2


1






I encounter the following scenarios when I try to use 2 forms. My workflow is as follows:



(1) Load Form1.



(2) A click on button1 on Form1 closes Form1 and opens Form2.



Solution A: If I use the following code:



Dim oForm As New Form2
oForm.ShowDialog()
Me.Close()


Then Form1 will be under Form2 (Form1 still opens).



Solution B: If I use the following code:



Dim oForm As New Form2
oForm.Show()
Me.Close()


Then Form1 closes and Form2 opens, but Form1 is not on the top layer.



I have looked through the solutions for this, most propose solution B, but for me, both solutions won't work the way I want. Can anybody tell me the reason?










share|improve this question
















I encounter the following scenarios when I try to use 2 forms. My workflow is as follows:



(1) Load Form1.



(2) A click on button1 on Form1 closes Form1 and opens Form2.



Solution A: If I use the following code:



Dim oForm As New Form2
oForm.ShowDialog()
Me.Close()


Then Form1 will be under Form2 (Form1 still opens).



Solution B: If I use the following code:



Dim oForm As New Form2
oForm.Show()
Me.Close()


Then Form1 closes and Form2 opens, but Form1 is not on the top layer.



I have looked through the solutions for this, most propose solution B, but for me, both solutions won't work the way I want. Can anybody tell me the reason?







vb.net forms






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 17 '18 at 2:41









Mozahler

2,20151927




2,20151927










asked Jul 2 '14 at 2:08









user30643user30643

1571412




1571412













  • Are you building a login dialogue?

    – Louis van Tonder
    Jul 2 '14 at 7:07











  • See my answer on a login scenario

    – Louis van Tonder
    Jul 2 '14 at 7:17






  • 1





    I feel like we are having to play 20 questions in order to find out essential information about what you are attempting. You need to put some effort in creating an example that will demonstrate your issue or post the code that you are using.

    – Mark Hall
    Jul 2 '14 at 16:16





















  • Are you building a login dialogue?

    – Louis van Tonder
    Jul 2 '14 at 7:07











  • See my answer on a login scenario

    – Louis van Tonder
    Jul 2 '14 at 7:17






  • 1





    I feel like we are having to play 20 questions in order to find out essential information about what you are attempting. You need to put some effort in creating an example that will demonstrate your issue or post the code that you are using.

    – Mark Hall
    Jul 2 '14 at 16:16



















Are you building a login dialogue?

– Louis van Tonder
Jul 2 '14 at 7:07





Are you building a login dialogue?

– Louis van Tonder
Jul 2 '14 at 7:07













See my answer on a login scenario

– Louis van Tonder
Jul 2 '14 at 7:17





See my answer on a login scenario

– Louis van Tonder
Jul 2 '14 at 7:17




1




1





I feel like we are having to play 20 questions in order to find out essential information about what you are attempting. You need to put some effort in creating an example that will demonstrate your issue or post the code that you are using.

– Mark Hall
Jul 2 '14 at 16:16







I feel like we are having to play 20 questions in order to find out essential information about what you are attempting. You need to put some effort in creating an example that will demonstrate your issue or post the code that you are using.

– Mark Hall
Jul 2 '14 at 16:16














7 Answers
7






active

oldest

votes


















3














Try



Dim oForm as New Form2

oForm.Show()


and on Load event of form2



Form1.Hide()





share|improve this answer

































    0














    Use form.bringtofront() if you want to see the opening Form in the front, I m little confused though about what you are trying to do






    share|improve this answer
























    • Hi, by using this, Form1 closed, Form2 not opened.

      – user30643
      Jul 2 '14 at 8:32











    • If you use Dim formsecond As New Form2() formsecond.show() formsecond.bringtofront() me.hide() or me.close(), it should work, I dont see why it would not work

      – user3758070
      Jul 2 '14 at 12:13





















    0














    Try doing it this way:



    Dim oForm As New Form2()

    Me.Hide()
    oForm.ShowDialog()

    Me.Close()





    share|improve this answer
























    • Thanks Baumi, I try this one but only Form1 closed, Form2 not appear.

      – user30643
      Jul 2 '14 at 8:30



















    0














    I suspect your are building a log-in dialogue... if so, or something similar, try this..



    Open your main form first... (Form 2), have form2 showdialog (modally) form1... this will put form1 on top of form2.



    Add a property to form 1, that gets set depending on what happens there.. sucessfull login for instance.



    Close form 1 from its own methods... (after successful authentication), set the property before closing.



    On form2, read this property of form1, and then dispose form1, and decide what to do... if unsuccessful login, show the login form again, end app. If successful, just gracefully exit out of the method that showed form1. Your form 2 is now the only form open.



    Start with Form2



    Form2_load



    dim f1 as new form1
    f1.showdialog
    if f1.someproperty = somevalue then

    ' do something here, for instance, pop the form again, if you did not get what you were lookign for...

    end if

    'gracefully let the function end and form2 is now the only open form..

    'dispose of form1. form1's close call does not dispose it, because it was opened modally. (showdialog)

    f1.dispose
    f1 = nothing


    in form1, depending on what you are doing, set the custom property and call me.close, this will exit the form, and run the next code in form2.






    share|improve this answer
























    • Hi Louis, thanks for your answer, I am not use log-in dialog, what I do is build a dll.

      – user30643
      Jul 2 '14 at 8:35



















    0














    try this:



    Dim oForm As New Form2

    oForm.Show()

    Me.Visible = False


    You would to close your first form and this close your program. If you set him on invisible, he is not closed.






    share|improve this answer































      0














      You wanted to close Form1 and open Form2 when Button1 is pressed, right? This code is for Button1 in Form1. You didn't tell much I don't know what exactly you are trying to do, but this is the EASIEST way to close a Form and open another Form by pressing a Button, always works for me



      Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
      Me.Close()
      Form2.Show()
      End Sub





      share|improve this answer































        -1














        Just go to form2 and write the Form1.hide() . I tried to close form1 but it closed my whole program.



        Public Class Form2
        Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Form1.Hide()
        End Sub
        End Class





        share|improve this answer


























          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f24521845%2fvb-net-using-a-button-on-a-form-to-open-another-form-doesnt-work%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          7 Answers
          7






          active

          oldest

          votes








          7 Answers
          7






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          3














          Try



          Dim oForm as New Form2

          oForm.Show()


          and on Load event of form2



          Form1.Hide()





          share|improve this answer






























            3














            Try



            Dim oForm as New Form2

            oForm.Show()


            and on Load event of form2



            Form1.Hide()





            share|improve this answer




























              3












              3








              3







              Try



              Dim oForm as New Form2

              oForm.Show()


              and on Load event of form2



              Form1.Hide()





              share|improve this answer















              Try



              Dim oForm as New Form2

              oForm.Show()


              and on Load event of form2



              Form1.Hide()






              share|improve this answer














              share|improve this answer



              share|improve this answer








              edited Dec 17 '14 at 0:32

























              answered Dec 16 '14 at 23:58









              Tarak BhavsarTarak Bhavsar

              8011




              8011

























                  0














                  Use form.bringtofront() if you want to see the opening Form in the front, I m little confused though about what you are trying to do






                  share|improve this answer
























                  • Hi, by using this, Form1 closed, Form2 not opened.

                    – user30643
                    Jul 2 '14 at 8:32











                  • If you use Dim formsecond As New Form2() formsecond.show() formsecond.bringtofront() me.hide() or me.close(), it should work, I dont see why it would not work

                    – user3758070
                    Jul 2 '14 at 12:13


















                  0














                  Use form.bringtofront() if you want to see the opening Form in the front, I m little confused though about what you are trying to do






                  share|improve this answer
























                  • Hi, by using this, Form1 closed, Form2 not opened.

                    – user30643
                    Jul 2 '14 at 8:32











                  • If you use Dim formsecond As New Form2() formsecond.show() formsecond.bringtofront() me.hide() or me.close(), it should work, I dont see why it would not work

                    – user3758070
                    Jul 2 '14 at 12:13
















                  0












                  0








                  0







                  Use form.bringtofront() if you want to see the opening Form in the front, I m little confused though about what you are trying to do






                  share|improve this answer













                  Use form.bringtofront() if you want to see the opening Form in the front, I m little confused though about what you are trying to do







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Jul 2 '14 at 4:27









                  user3758070user3758070

                  264




                  264













                  • Hi, by using this, Form1 closed, Form2 not opened.

                    – user30643
                    Jul 2 '14 at 8:32











                  • If you use Dim formsecond As New Form2() formsecond.show() formsecond.bringtofront() me.hide() or me.close(), it should work, I dont see why it would not work

                    – user3758070
                    Jul 2 '14 at 12:13





















                  • Hi, by using this, Form1 closed, Form2 not opened.

                    – user30643
                    Jul 2 '14 at 8:32











                  • If you use Dim formsecond As New Form2() formsecond.show() formsecond.bringtofront() me.hide() or me.close(), it should work, I dont see why it would not work

                    – user3758070
                    Jul 2 '14 at 12:13



















                  Hi, by using this, Form1 closed, Form2 not opened.

                  – user30643
                  Jul 2 '14 at 8:32





                  Hi, by using this, Form1 closed, Form2 not opened.

                  – user30643
                  Jul 2 '14 at 8:32













                  If you use Dim formsecond As New Form2() formsecond.show() formsecond.bringtofront() me.hide() or me.close(), it should work, I dont see why it would not work

                  – user3758070
                  Jul 2 '14 at 12:13







                  If you use Dim formsecond As New Form2() formsecond.show() formsecond.bringtofront() me.hide() or me.close(), it should work, I dont see why it would not work

                  – user3758070
                  Jul 2 '14 at 12:13













                  0














                  Try doing it this way:



                  Dim oForm As New Form2()

                  Me.Hide()
                  oForm.ShowDialog()

                  Me.Close()





                  share|improve this answer
























                  • Thanks Baumi, I try this one but only Form1 closed, Form2 not appear.

                    – user30643
                    Jul 2 '14 at 8:30
















                  0














                  Try doing it this way:



                  Dim oForm As New Form2()

                  Me.Hide()
                  oForm.ShowDialog()

                  Me.Close()





                  share|improve this answer
























                  • Thanks Baumi, I try this one but only Form1 closed, Form2 not appear.

                    – user30643
                    Jul 2 '14 at 8:30














                  0












                  0








                  0







                  Try doing it this way:



                  Dim oForm As New Form2()

                  Me.Hide()
                  oForm.ShowDialog()

                  Me.Close()





                  share|improve this answer













                  Try doing it this way:



                  Dim oForm As New Form2()

                  Me.Hide()
                  oForm.ShowDialog()

                  Me.Close()






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Jul 2 '14 at 7:03









                  BaumiBaumi

                  25426




                  25426













                  • Thanks Baumi, I try this one but only Form1 closed, Form2 not appear.

                    – user30643
                    Jul 2 '14 at 8:30



















                  • Thanks Baumi, I try this one but only Form1 closed, Form2 not appear.

                    – user30643
                    Jul 2 '14 at 8:30

















                  Thanks Baumi, I try this one but only Form1 closed, Form2 not appear.

                  – user30643
                  Jul 2 '14 at 8:30





                  Thanks Baumi, I try this one but only Form1 closed, Form2 not appear.

                  – user30643
                  Jul 2 '14 at 8:30











                  0














                  I suspect your are building a log-in dialogue... if so, or something similar, try this..



                  Open your main form first... (Form 2), have form2 showdialog (modally) form1... this will put form1 on top of form2.



                  Add a property to form 1, that gets set depending on what happens there.. sucessfull login for instance.



                  Close form 1 from its own methods... (after successful authentication), set the property before closing.



                  On form2, read this property of form1, and then dispose form1, and decide what to do... if unsuccessful login, show the login form again, end app. If successful, just gracefully exit out of the method that showed form1. Your form 2 is now the only form open.



                  Start with Form2



                  Form2_load



                  dim f1 as new form1
                  f1.showdialog
                  if f1.someproperty = somevalue then

                  ' do something here, for instance, pop the form again, if you did not get what you were lookign for...

                  end if

                  'gracefully let the function end and form2 is now the only open form..

                  'dispose of form1. form1's close call does not dispose it, because it was opened modally. (showdialog)

                  f1.dispose
                  f1 = nothing


                  in form1, depending on what you are doing, set the custom property and call me.close, this will exit the form, and run the next code in form2.






                  share|improve this answer
























                  • Hi Louis, thanks for your answer, I am not use log-in dialog, what I do is build a dll.

                    – user30643
                    Jul 2 '14 at 8:35
















                  0














                  I suspect your are building a log-in dialogue... if so, or something similar, try this..



                  Open your main form first... (Form 2), have form2 showdialog (modally) form1... this will put form1 on top of form2.



                  Add a property to form 1, that gets set depending on what happens there.. sucessfull login for instance.



                  Close form 1 from its own methods... (after successful authentication), set the property before closing.



                  On form2, read this property of form1, and then dispose form1, and decide what to do... if unsuccessful login, show the login form again, end app. If successful, just gracefully exit out of the method that showed form1. Your form 2 is now the only form open.



                  Start with Form2



                  Form2_load



                  dim f1 as new form1
                  f1.showdialog
                  if f1.someproperty = somevalue then

                  ' do something here, for instance, pop the form again, if you did not get what you were lookign for...

                  end if

                  'gracefully let the function end and form2 is now the only open form..

                  'dispose of form1. form1's close call does not dispose it, because it was opened modally. (showdialog)

                  f1.dispose
                  f1 = nothing


                  in form1, depending on what you are doing, set the custom property and call me.close, this will exit the form, and run the next code in form2.






                  share|improve this answer
























                  • Hi Louis, thanks for your answer, I am not use log-in dialog, what I do is build a dll.

                    – user30643
                    Jul 2 '14 at 8:35














                  0












                  0








                  0







                  I suspect your are building a log-in dialogue... if so, or something similar, try this..



                  Open your main form first... (Form 2), have form2 showdialog (modally) form1... this will put form1 on top of form2.



                  Add a property to form 1, that gets set depending on what happens there.. sucessfull login for instance.



                  Close form 1 from its own methods... (after successful authentication), set the property before closing.



                  On form2, read this property of form1, and then dispose form1, and decide what to do... if unsuccessful login, show the login form again, end app. If successful, just gracefully exit out of the method that showed form1. Your form 2 is now the only form open.



                  Start with Form2



                  Form2_load



                  dim f1 as new form1
                  f1.showdialog
                  if f1.someproperty = somevalue then

                  ' do something here, for instance, pop the form again, if you did not get what you were lookign for...

                  end if

                  'gracefully let the function end and form2 is now the only open form..

                  'dispose of form1. form1's close call does not dispose it, because it was opened modally. (showdialog)

                  f1.dispose
                  f1 = nothing


                  in form1, depending on what you are doing, set the custom property and call me.close, this will exit the form, and run the next code in form2.






                  share|improve this answer













                  I suspect your are building a log-in dialogue... if so, or something similar, try this..



                  Open your main form first... (Form 2), have form2 showdialog (modally) form1... this will put form1 on top of form2.



                  Add a property to form 1, that gets set depending on what happens there.. sucessfull login for instance.



                  Close form 1 from its own methods... (after successful authentication), set the property before closing.



                  On form2, read this property of form1, and then dispose form1, and decide what to do... if unsuccessful login, show the login form again, end app. If successful, just gracefully exit out of the method that showed form1. Your form 2 is now the only form open.



                  Start with Form2



                  Form2_load



                  dim f1 as new form1
                  f1.showdialog
                  if f1.someproperty = somevalue then

                  ' do something here, for instance, pop the form again, if you did not get what you were lookign for...

                  end if

                  'gracefully let the function end and form2 is now the only open form..

                  'dispose of form1. form1's close call does not dispose it, because it was opened modally. (showdialog)

                  f1.dispose
                  f1 = nothing


                  in form1, depending on what you are doing, set the custom property and call me.close, this will exit the form, and run the next code in form2.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Jul 2 '14 at 7:17









                  Louis van TonderLouis van Tonder

                  2,45232151




                  2,45232151













                  • Hi Louis, thanks for your answer, I am not use log-in dialog, what I do is build a dll.

                    – user30643
                    Jul 2 '14 at 8:35



















                  • Hi Louis, thanks for your answer, I am not use log-in dialog, what I do is build a dll.

                    – user30643
                    Jul 2 '14 at 8:35

















                  Hi Louis, thanks for your answer, I am not use log-in dialog, what I do is build a dll.

                  – user30643
                  Jul 2 '14 at 8:35





                  Hi Louis, thanks for your answer, I am not use log-in dialog, what I do is build a dll.

                  – user30643
                  Jul 2 '14 at 8:35











                  0














                  try this:



                  Dim oForm As New Form2

                  oForm.Show()

                  Me.Visible = False


                  You would to close your first form and this close your program. If you set him on invisible, he is not closed.






                  share|improve this answer




























                    0














                    try this:



                    Dim oForm As New Form2

                    oForm.Show()

                    Me.Visible = False


                    You would to close your first form and this close your program. If you set him on invisible, he is not closed.






                    share|improve this answer


























                      0












                      0








                      0







                      try this:



                      Dim oForm As New Form2

                      oForm.Show()

                      Me.Visible = False


                      You would to close your first form and this close your program. If you set him on invisible, he is not closed.






                      share|improve this answer













                      try this:



                      Dim oForm As New Form2

                      oForm.Show()

                      Me.Visible = False


                      You would to close your first form and this close your program. If you set him on invisible, he is not closed.







                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered Jul 2 '14 at 12:51









                      MonauralMass371MonauralMass371

                      65




                      65























                          0














                          You wanted to close Form1 and open Form2 when Button1 is pressed, right? This code is for Button1 in Form1. You didn't tell much I don't know what exactly you are trying to do, but this is the EASIEST way to close a Form and open another Form by pressing a Button, always works for me



                          Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
                          Me.Close()
                          Form2.Show()
                          End Sub





                          share|improve this answer




























                            0














                            You wanted to close Form1 and open Form2 when Button1 is pressed, right? This code is for Button1 in Form1. You didn't tell much I don't know what exactly you are trying to do, but this is the EASIEST way to close a Form and open another Form by pressing a Button, always works for me



                            Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
                            Me.Close()
                            Form2.Show()
                            End Sub





                            share|improve this answer


























                              0












                              0








                              0







                              You wanted to close Form1 and open Form2 when Button1 is pressed, right? This code is for Button1 in Form1. You didn't tell much I don't know what exactly you are trying to do, but this is the EASIEST way to close a Form and open another Form by pressing a Button, always works for me



                              Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
                              Me.Close()
                              Form2.Show()
                              End Sub





                              share|improve this answer













                              You wanted to close Form1 and open Form2 when Button1 is pressed, right? This code is for Button1 in Form1. You didn't tell much I don't know what exactly you are trying to do, but this is the EASIEST way to close a Form and open another Form by pressing a Button, always works for me



                              Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
                              Me.Close()
                              Form2.Show()
                              End Sub






                              share|improve this answer












                              share|improve this answer



                              share|improve this answer










                              answered Jul 3 '14 at 9:44









                              user7777777user7777777

                              353110




                              353110























                                  -1














                                  Just go to form2 and write the Form1.hide() . I tried to close form1 but it closed my whole program.



                                  Public Class Form2
                                  Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
                                  Form1.Hide()
                                  End Sub
                                  End Class





                                  share|improve this answer






























                                    -1














                                    Just go to form2 and write the Form1.hide() . I tried to close form1 but it closed my whole program.



                                    Public Class Form2
                                    Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
                                    Form1.Hide()
                                    End Sub
                                    End Class





                                    share|improve this answer




























                                      -1












                                      -1








                                      -1







                                      Just go to form2 and write the Form1.hide() . I tried to close form1 but it closed my whole program.



                                      Public Class Form2
                                      Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
                                      Form1.Hide()
                                      End Sub
                                      End Class





                                      share|improve this answer















                                      Just go to form2 and write the Form1.hide() . I tried to close form1 but it closed my whole program.



                                      Public Class Form2
                                      Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
                                      Form1.Hide()
                                      End Sub
                                      End Class






                                      share|improve this answer














                                      share|improve this answer



                                      share|improve this answer








                                      edited Nov 19 '18 at 7:45









                                      UmAnusorn

                                      3,97744870




                                      3,97744870










                                      answered Nov 16 '18 at 13:53









                                      user10663225user10663225

                                      1




                                      1






























                                          draft saved

                                          draft discarded




















































                                          Thanks for contributing an answer to Stack Overflow!


                                          • Please be sure to answer the question. Provide details and share your research!

                                          But avoid



                                          • Asking for help, clarification, or responding to other answers.

                                          • Making statements based on opinion; back them up with references or personal experience.


                                          To learn more, see our tips on writing great answers.




                                          draft saved


                                          draft discarded














                                          StackExchange.ready(
                                          function () {
                                          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f24521845%2fvb-net-using-a-button-on-a-form-to-open-another-form-doesnt-work%23new-answer', 'question_page');
                                          }
                                          );

                                          Post as a guest















                                          Required, but never shown





















































                                          Required, but never shown














                                          Required, but never shown












                                          Required, but never shown







                                          Required, but never shown

































                                          Required, but never shown














                                          Required, but never shown












                                          Required, but never shown







                                          Required, but never shown







                                          Popular posts from this blog

                                          Xamarin.iOS Cant Deploy on Iphone

                                          Glorious Revolution

                                          Dulmage-Mendelsohn matrix decomposition in Python