How to run a procedure in a form and then automatically close it?
-
2008年12月13日 2:42
I use Visual Studio 2005. In VB, it should able to close a form by me.close() but when I put the code in activated event, the program does not return the control to Visual Studio and no form is appeared. I need manually to push the stop debugging icon to return the control to the Visual Studio. Anyone can help?
所有回覆
-
2008年12月13日 3:43
You may try Application.Exit() to exit the program.
-
2008年12月19日 8:41
In .NET, if you write VB, You should now learn the new coding way.
Normally we will create a new Class File and then create a Sub Main in it. And then set the Project Startup File is the class.
Then you call Application.Run(new Form1())
More detail in the following link,
Application.Run Method
http://msdn.microsoft.com/en-us/library/system.windows.forms.application.run(VS.71).aspx
-
2008年12月22日 14:08
I just want to run a procedure and then close. In fact, there is no need to have a form.
-
2008年12月23日 2:01
I think you should create a ConsoleApplication rather than a WindowsApplication. By default create a ConsoleApplication, you will have a Module1 with Sub Main. You can write your procedure in Sub Main. No form will created. After the Sub Main finish will exit the program. -
2009年1月7日 6:03
Hi,
I think even it is a winform application, you still can use "application.exit" to close / exist from the application.
As long as we can complete the program, no matter it is console app or WinForm app.