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
Printable View
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
VB Code:
Application.Exit()
Or instruct the user to type : exit and hit enter . I believe it works .
Application.Exit() is not recognized and exit didn't work either!
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?
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
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 .
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.
I tried to build the console solution and it successfully done with no errors . Are you running Standard VB.NET version ?
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 ?Quote:
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.)
Yes! as you suggested yesterday
Just set any obj you want to destroy to Nothing as this :
VB Code:
MyObj =Nothing
Here is how you can end a console application.
using System.Threading;
Process.GetCurrentProcess().Kill(); // Kills this program...
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]