Results 1 to 15 of 15

Thread: End Console application

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2002
    Posts
    320

    End Console application

    I'm writing a console Application in VB.NET. I give user a list of menus to choose from and the last one is Enter 'Q' to quit.
    Please let me know what command will actually close the console window.
    thnx

  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    VB Code:
    1. Application.Exit()

  3. #3
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Or instruct the user to type : exit and hit enter . I believe it works .

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2002
    Posts
    320
    Application.Exit() is not recognized and exit didn't work either!

  5. #5
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Did you import System.Windows.Forms.dll to get the first one working?

    Did you try typing 'exit' and hitting enter in the console window?

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2002
    Posts
    320
    Since it is a console appllcation i.e. a module then how can we write
    import System.Windows.Forms.dll
    Secondly I'm presenting menu with console.Writeline and get the user input with console.readling commands.
    It does not exit with command exit and then enter.
    thanks

  7. #7
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Add reference to that dll where you can find it in the .NET tab. Then type " Imports System.Windows.Forms" at the very top of the module .

  8. #8

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2002
    Posts
    320
    I tried to add the reference, but got an error saying:

    'A reference to System.Windows.Forms.dll could not be added.Converting the type Library to .Net assembly failed. Type Library System_Windows_Forms was exported from a CLR assembly and cannot be re-imported as CLR assembly.'

    Please suggest some remedy.

  9. #9
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    I tried to build the console solution and it successfully done with no errors . Are you running Standard VB.NET version ?

  10. #10

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2002
    Posts
    320
    Actually I was trying to set reference from the com tab. Now I could set the reference, add the imports statement

    Imports System.Windows.Forms
    and the command Application.exit

    But this doesn't exit the application. Rather 'End' command is working (although I never used it in VB6 since it leaves the references hanging in memory.)

  11. #11
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Originally posted by ssingh
    Actually I was trying to set reference from the com tab. Now I could set the reference, add the imports statement

    Imports System.Windows.Forms
    and the command Application.exit

    But this doesn't exit the application. Rather 'End' command is working (although I never used it in VB6 since it leaves the references hanging in memory.)
    What reference are you talking about ? Maybe System.Windows.Forms.dll ?

  12. #12

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2002
    Posts
    320
    Yes! as you suggested yesterday

  13. #13
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Just set any obj you want to destroy to Nothing as this :
    VB Code:
    1. MyObj =Nothing

  14. #14
    New Member
    Join Date
    Sep 2006
    Posts
    1

    Re: End Console application

    Here is how you can end a console application.

    using System.Threading;

    Process.GetCurrentProcess().Kill(); // Kills this program...

  15. #15
    New Member
    Join Date
    Dec 2010
    Posts
    1

    Re: End Console application

    See, this is why VB developers are looked down upon. Guys, this is not rocket science!

    [VBCODE]Sub Main()
    Return 'RETURNS from the main application method.
    End Sub[/VBCODE]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width