is this code correct?

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

That code should work.

but it only close the current window and not opening the Form2 .

Go to the project properties and in the application tab change the shutdown mode to when the last form closes.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.