Vb.net 刽子手不工作

Vb.net 刽子手不工作,vb.net,Vb.net,我正在用VB做一个刽子手游戏。谢谢你的帮助 我所能做的就是玩家1输入一个单词。然后程序将其放入一个数组,该数组将其排序为字母。播放器2(在同一台计算机上)尝试猜单词,一次猜一个字母。他们输入一个字母,程序将通过数组检查单词中是否有字母。如果有,它将显示字母(其他字母留空),并将评分系统保留在10(我仍然需要将此输入),如果他们猜错,字母将保持覆盖,并将减去评分系统的1 Module Module1 Sub Main() Dim myword, guess As String D

我正在用VB做一个刽子手游戏。谢谢你的帮助

我所能做的就是玩家1输入一个单词。然后程序将其放入一个数组,该数组将其排序为字母。播放器2(在同一台计算机上)尝试猜单词,一次猜一个字母。他们输入一个字母,程序将通过数组检查单词中是否有字母。如果有,它将显示字母(其他字母留空),并将评分系统保留在10(我仍然需要将此输入),如果他们猜错,字母将保持覆盖,并将减去评分系统的1

Module Module1

Sub Main()
    Dim myword, guess As String
    Dim mywordlen As Integer
    Dim flag As Boolean
    Console.WriteLine("Player 1, please enter a word to guess")
    myword = Console.ReadLine()
    mywordlen = myword.Length
    Dim answer(mywordlen) As Char

    For x = 0 To mywordlen - 1
        answer(x) = "_"
        While answer > 0 Then 
            Console.WriteLine("Please guess a letter")
            guess = Console.ReadLine()
            flag = False
            For x = 0 To mywordlen - 1
                If guess = myword Then {0}
                    answer(x) = guess
                    flag = True
                    Console.WriteLine("The answer is, {0}")
            Next
    Next
End Sub

你得到了什么错误?在哪一行?代码甚至没有编译。你知道这种系统是如何工作的吗??我所能做的就是玩家1输入一个单词。然后程序将其放入一个数组,该数组将其排序为字母。播放器2(在同一台计算机上)尝试猜单词,一次猜一个字母。他们输入一个字母,程序将通过数组检查单词中是否有字母。如果有,它将显示字母(其他字母留空),并将评分系统保留在10(我仍然需要将此输入),如果他们猜错,字母将保持覆盖,并将减去评分系统的1。检查语法-似乎您需要完成更多的教程。你有一个
While
没有
End的While
,你有一个
If
没有
End的If
,你在一个
Char()
和一个数字之间建立了一个比较,你在重新定义一个循环变量,IDE中的错误列表将为您提供所有这些问题的具体列表及其发生的行。编程是一门非常精确的学科——你不能只键入任何内容,就指望编译器理解你想要的内容。这里有语言语法的规则和描述它们的大量文档。好的,谢谢。所以如果我加上一个end while和一个end while,这将有助于解决我的问题。我应该为char部分使用什么代码。我想当他们输入一封信时,一个字符就行了?
Dim myword, guess As String
Dim mywordlen, x As Integer
Dim flag As Boolean
Console.WriteLine("Player 1, please enter a word to guess")
myword = Console.ReadLine()
mywordlen = myword.Length - 1
Dim answer(mywordlen), displayword(mywordlen) As Char
Dim score As Integer = 10

For x = 0 To mywordlen
    answer(x) = Mid(myword, x + 1, 1)
    displayword(x) = "_"
Next
While score > 0 
    Console.WriteLine("Please guess a letter")
    guess = Console.ReadLine()  'Assumes user only types one letter
    flag = False
    For x = 0 To mywordlen
        If guess = answer(x) Then
            displayword(x) = guess
            flag = True
        End If
    Next
    If flag Then
        If New String(displayword) = myword Then
            Console.WriteLine("Congratulations! You won!")
            Exit While
        Else
            Console.WriteLine("Correct! {0}", New String(displayword))
        End If
    Else
        Console.WriteLine("Incorrect. {0}", New String(displayword))
        score -= 1
    End If
End While
Console.WriteLine("Game over. The word was {0}", myword)