Change Windows

I have a project and on this project I do have 3 Froms.
1 form1
2 john
3 creation

I want to know that if I put a button on form1 how do I get it to go to a next form.

What and how must I do this

Thanks


Answer this question

Change Windows

  • Chris0144

    you have to keep track of all the forms in your main form - this main form will open and close all child forms.

    DialogResult result = john.ShowDialog();

    if(result ==DialogResult.OK)
    {

    ....

    }


    thats the routine

  • Ertan Köseler

    You could also have each form linked in order and not have a "main" form, per say...

    Start your app with a Sub Main():


        Sub Main()

            Dim f As New Form1
            f.Show()
            Application.Run()

        End Sub


    Then in the "Next" Button_Click event on Form1 you do:



        Private Sub NextButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NextButton.Click

            Dim f As New John
            f.Show()
            Me.Close()

        End Sub


    And the same in John for Creation:



        Private Sub NextButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NextButton.Click

            Dim f As New Creation
            f.Show()
            Me.Close()

        End Sub


    Creation then needs one more line in either a "Finish" button's click event or in the Form.Closing event:


        Private Sub Creation_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing

            Application.Exit()

        End Sub


    That would give you a "Next, Next, Finish" or "wizard" style structure.

  • Change Windows