I have 2 forms right now Form1 and Form2 the default setting start up is Form2. Inside Form 2 there was a button that will release the Form1 button using Form1.Show().

I have now the problem. What I want to do now is to close the Form2 without closing the Form1.

inside Form2 button:

Button_Click....
Form1.Show()
'End
End sub

is there any way that solves my problem?

You cant. The Form2 was stared as the Main form in the Main method. You can only Hide it (use this.Hide() method), if you will close it, the whole application will close.

There is maybe another solution:

Private Shared Sub Main()
	Application.EnableVisualStyles()
	Application.SetCompatibleTextRenderingDefault(False)
	Application.Run(New Form1())
	' Form1 in this Application.
	Application.Run(New Form2())
	' Form2 in this application.
End Sub

.. if you want Form2 to open after Form1 exits. There's no going back. When Form2 closes, the programs end.

or:

Imports System.Windows.Forms
Imports Microsoft.VisualBasic.ApplicationServices

Namespace WindowsApplication1
	Public Class MyApp
		Inherits WindowsFormsApplicationBase
		Public Sub New()
			Me.ShutdownStyle = ShutdownMode.AfterAllFormsClose
			Me.MainForm = New Form1()
		End Sub
	End Class
	NotInheritable Class Program
		Private Sub New()
		End Sub
		<STAThread> _
		Private Shared Sub Main(args As String())
			Dim app As New MyApp()
			app.Run(args)
		End Sub
	End Class
End Namespace

You can now close your startup form (Form1) without problems. Your program will exit when the last form is closed.

Edited 5 Years Ago by Mitja Bonca: n/a

This question has already been answered. Start a new discussion instead.