I created a VB project of the type Console App (.Net Framework). The objective of the below code is to make a FORM appear and then immediately disappear. However although the form is appearing correctly it is not closing by itself. Can anyone pls help pointing out my mistake? I tried to see how the control moves by setting up a break point and found that after executing the statement Application.Run(New Form1)
(i.e. after launching the form) the control does not move to the next statement Application.Exit()
by itself. Only when I manually close the FORM (by clicking on x icon) do I find the control moving to the Application.Exit() statement. But then I have already closed the form manually so does this statement at all do anything? If not, then how to modify the code to make the FORM automatically close after being visible.
Imports System.Windows.Forms
Public Class Form1
Inherits Form 'System.Windows.Forms.Form
End Class
Module Module1
Sub Main() 'launches the console window
Application.Run(New Form1) 'Opens a new Form
Application.Exit(0) 'Supposed to close the form that was opened but not closing
End Sub 'closes the console window
End Module
Also, please note I am deliberately not creating a WPF application as I want to understand how the classes/commands under the System.Windows.Forms namespace work.
Regards,
Sougata Ghosh