locked
How to run a procedure in a form and then automatically close it? RRS feed

  • Pergunta

  • 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?

    sábado, 13 de dezembro de 2008 02:42

Respostas

  • 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

    sexta-feira, 19 de dezembro de 2008 08:41
  •  

    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.
    terça-feira, 23 de dezembro de 2008 02:01

Todas as Respostas

  •  

    You may try Application.Exit() to exit the program.

    sábado, 13 de dezembro de 2008 03:43
  • 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

    sexta-feira, 19 de dezembro de 2008 08:41
  • I just want to run a procedure and then close.  In fact, there is no need to have a form.

    segunda-feira, 22 de dezembro de 2008 14:08
  •  

    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.
    terça-feira, 23 de dezembro de 2008 02:01
  • 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. 

    quarta-feira, 7 de janeiro de 2009 06:03