如何使私有子回到sub main()

时间:2015-10-26 02:00:13

标签: vb.net vb.net-2010

好的,我有我的所有程序,什么不是,只是我不知道如何阻止它在执行

后退出程序
private sub

例如,我有

 Private Sub KeyList()
    Console.WriteLine("1.) File - Opens a test file")
    Console.WriteLine("2.) Update - Updates the program using an external .bat file")
    Console.WriteLine("3.) Username - ReDo Your username")
    Console.WriteLine("4.) Site - Starts your browser and leads you to our site :D")
    Console.WriteLine("5.) PLUGIN_STRT_NOPROT - Starts the loaded plugin without layered protection, do not do this unless you know")
    Console.WriteLine("what you are doing")
    Console.WriteLine("6.) PLUGIN_STRT_PROT - Starts loaded plugin with protection, reccomended.")
    Console.WriteLine("7.) API_Str_Rand - Creates a random API string that you can assign to a plugin.")
    Console.WriteLine("8) DownloadDevKit - Downloads the developmental kit to create a plugin")

End Sub

但在我点击任何其他键后,程序终止。如何阻止程序终止,并返回

sub main() 

这是我整个程序的数据代码,它是VB.net 2010.

    Module Module1
Sub Main()
    REM Add all the Dimensions/Descriptions here.
    Dim VersionName As String = "1"
    Dim Action As String = "Action"
    Dim username As String = "UserName"
    REM The Visual part of the program. No pun intended :>

    REM Ask the name for the session.
    username:
    Console.WriteLine("Hello, What is your name? ")
    username = Console.ReadLine()
    Console.WriteLine("Hello " + username)
    If username = "Skycoder" Then
        Console.WriteLine("Welcome back!, Planned updates to include in this are, 1.) ADd in more key features")
        Console.WriteLine("2.) Add hotkeys")
        Console.WriteLine("3.) Implement and auto updater")
        Console.Beep()
        If username = "" Then
            Console.WriteLine("Please type in name. Numerals can be used")
            GoTo username
        End If
    End If
    Fish:
    Console.ReadLine()
    Console.Clear()
    Console.Title = ("Desktop TBI | Hello " + username)
    Console.WriteLine("-----------------------------------------------------------------------------------------------------------")
    Console.WriteLine("Please select an option, note that this is a work in progress, and will contain more features in the future")
    Console.WriteLine("")
    Console.WriteLine("                 Type 'File' to create the directory (Important if you want to add plugins)")
    Console.WriteLine("                                    Using Version: " + VersionName)
    Console.WriteLine("-----------------------------------------------------------------------------------------------------------")
    Console.WriteLine("                             Please choose what action you want to do")
    Console.WriteLine("                               Type in 'File' To find the directory")
    Console.WriteLine("                 Type in 'Update' To open the .bat file to download the updates")
    Console.WriteLine("-----------------------------------------------------------------------------------------------------------")
    Console.WriteLine("To create the new path, enter 'CreateDir'")
    REM Begin the part where users can select their code.
    Dim selection As String = Console.ReadLine
    Select Case selection
        REM This allows the creation of a text file.
        Case "File"
            Console.Clear()
            File() REM Private sub selection
            REM Updates their program.
        Case "Username"
            Console.Clear()
            GoTo UserName
            REM Set's their username for the program.
        Case "Update"
            Update()
        Case "KeyList"
            KeyList()
        Case "CreateDir"
            CreateDir()
        Case "SERV_Start"
            Chat_Start_SERV()
        Case "Site"
            Site()
            Console.ReadLine()
    End Select
End Sub       

但是在我选择了我想要使用的案例并进入子代码之后 键列表,它只是终止,它甚至不等我阅读它。如果它可以帮助任何人,我会真的提供它发生的视频......我很绝望......

2 个答案:

答案 0 :(得分:1)

Select case块放入循环中,再添加一个选项("退出"例如) - 如果选择该选项,则退出循环并退出应用程序。

Console.WriteLine("0) Exit - Exit application")

Dim selection As String = Console.ReadLine()
While selection.Equals("Exit") = false
    Select Case selection
        REM This allows the creation of a text file.
        Case "File"
            Console.Clear()
            File() REM Private sub selection
        '...
        '... other Case values
        '...

    End Select
    selection = Console.ReadLine()
Loop

答案 1 :(得分:0)

如果用户输入"网站"此应用程序将仅点击Console.ReadLine()。将Readline语句移到End Select语句下方,它将执行您想要的操作。