如何关闭Visual Basic控制台应用程序?

时间:2018-04-04 16:23:22

标签: vb.net console-application

我想知道是否有一行代码我可以输入,在执行时终止控制台应用程序。我已经尝试过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

0 个答案:

没有答案