我想知道是否有一行代码我可以输入,在执行时终止控制台应用程序。我已经尝试过Environment.exit(0)并且没有用。非常感谢任何帮助,谢谢。
这是我到目前为止的代码:
Sub Exit_Program()
Console.Clear()
Console.WriteLine("************************************************")
Console.WriteLine(" ")
Console.WriteLine("Are you sure you want to exit? if so type 'exit' or type 'back' to get back to the main menu.")
Console.WriteLine(" ")
Console.WriteLine("************************************************")
Dim Exit_confirm As String
Exit_confirm_error:
Try
Exit_confirm = Console.ReadLine()
Catch
Console.WriteLine(" ")
Console.WriteLine(" Error: Are you sure you want to exit? if so type 'exit' or type 'back' to get back to the main menu.")
Console.WriteLine(" ")
GoTo Exit_confirm_error
End Try
Select Case Exit_confirm
Case "exit"
' code that terminates the console application (?)
Case "back"
Main()
Case Else
Console.WriteLine(" ")
Console.WriteLine(" Error: Are you sure you want to exit? if so type 'exit' or type 'back' to get back to the main menu.")
Console.WriteLine(" ")
GoTo Exit_confirm_error
End Select
End Sub