The goal is to opening a new form by clicking a button in the old form and at the same time the old form will be closed. How to do that?
Following code is giving me error.
Public Class Form1
Dim secondForm As Form2
Dim firstForm As Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
You're trying to declare an object of the class within the definition of the class itself.
Also, secondForm would belong to firstForm, so, IIRC, if you close firstForm, you'd also lose secondForm.
Way out: In the module, form, or class that creates the instances of Form1 and Form2, put in an event handler for the button click on the Form1 instance and deal with the showing and hiding/closing there.