Vb.net 为什么我的代码不能返回主菜单?

Vb.net 为什么我的代码不能返回主菜单?,vb.net,Vb.net,我正在VB.Net中创建一个猜数字游戏。我已经到了一个地步,我在问球员,在他们赢了之后,他们是否愿意再次比赛。当我尝试将他们送回主菜单时,如果他们选择要再次播放,它将退出程序 Sub MainMenu() Console.WriteLine("Main Menu") Console.WriteLine("1) Play Game") Console.WriteLine("2) Instructions") Console.Writ

我正在VB.Net中创建一个猜数字游戏。我已经到了一个地步,我在问球员,在他们赢了之后,他们是否愿意再次比赛。当我尝试将他们送回主菜单时,如果他们选择要再次播放,它将退出程序

 Sub MainMenu()
        Console.WriteLine("Main Menu")
        Console.WriteLine("1) Play Game")
        Console.WriteLine("2) Instructions")
        Console.WriteLine("3) View Score")
        Console.WriteLine("4) Exit")
        Console.WriteLine()
    End Sub

If UserGuess = CorrectNumber Then 
            PlayerScore = PlayerScore + 1
            Console.WriteLine("...CORRECT!!! You win!")
            Console.WriteLine("You took " & NOfGuesses & " guesses!")
            Console.WriteLine("Press Enter to Continue")
            Console.ReadLine()
            Console.Clear()
            PlayAgainSub()
        End If

Sub PlayAgainSub()
        Dim PlayAgain As Char
        Console.Clear()
        Console.WriteLine("Would you like to play again? (Y/N)")
        PlayAgain = Console.ReadLine.ToUpper
        If PlayAgain = "Y" Then
            MainMenu()
        ElseIf PlayAgain = "N" Then
            Quit()
        Else
            Console.WriteLine("Option not valid!")
            REM Next line waits for 0.5 seconds so the user has time to see the error message.
            Threading.Thread.Sleep(500)
            Console.Clear()
            PlayAgainSub()
        End If
    End Sub

这不是全部代码,只是我认为相关的,如果您需要其余的代码,我将更新帖子。

为递归示例设置一个变量 模糊重现为字符
然后用Do。。循环while

因为该方法不会像Console.ReadLine那样停止执行,您只需将行输出到控制台,如果playreach=Y,则主菜单中没有ReadLine…我明白了,谢谢,我现在就试试。它应该会给您足够的信息,让您自己修复它。这不是完整的代码,例如,如果UserGuess=CorrectNumber介于两个方法之间。@JakeMills:在显示主菜单后提示并读取用户输入。在此应用程序中,您还可以从何处接收用户输入?它会像那样工作的。明白了,它现在工作得很好,非常感谢你的帮助。