Calling a second form and closing the first form (1 Viewer)

Ryobi

Registered User.
Local time
Today, 11:39
Joined
Mar 5, 2012
Messages
49
I have search the web but I can not find how to open a second form and close the first form. I have try different codes (including trying to close it from the second form) but none seem to work. The code below will close the first and second form which is not what I need. I want the first form to close when the second form is opened. The code in the loading section of the first form.


Me.Hide()
Form2.Show()
Me.Close()


This is possible in vb.net ?
 

June7

AWF VIP
Local time
Today, 08:39
Joined
Mar 9, 2014
Messages
5,423
Try explicitly naming the form to act on instead of the alias Me.
 

Ryobi

Registered User.
Local time
Today, 11:39
Joined
Mar 5, 2012
Messages
49
I have also tried that but I get an error message stating that the form has been moved. Basically it does not work.
 

June7

AWF VIP
Local time
Today, 08:39
Joined
Mar 9, 2014
Messages
5,423
A tutorial I looked at showed use of Show and Hide. Unfortunately, I am not familiar enough with vb.net to advise further.

Unless you really mean to use VBA?
 

Ryobi

Registered User.
Local time
Today, 11:39
Joined
Mar 5, 2012
Messages
49
I am using Vb.net. Thank you for trying.
 

Ryobi

Registered User.
Local time
Today, 11:39
Joined
Mar 5, 2012
Messages
49
I have the found the solution. It is to change the following setting:
"Project" menu -> 'YourApp' Properties... -> Application Tab
find : "Shutdown Mode"
Change from
"When startup form closes" --> "When last form closes"

I hope this helps other users.

Import note: If you are using more then one project you need change the setting on all projects.

 

Users who are viewing this thread

Top Bottom