文字列全体を反復処理しないようにするにはどうすればよいでしょうか?これはハングマンのゲームであることを頭に入れたランダムな文字列の入力と一致します。ユーザーが選択した文字が8回以上表示されるのではなく、正しくまたは間違っている場合は、1回だけ表示します。ハングマンで文字列全部をコード化するコード
Sub letterInput()
For i As Integer = 0 To randomWord.Length - 1
If userInput = randomWord(i) Then
MessageBox.Show("correct")
ElseIf userInput <> randomWord(i) Then
MessageBox.Show("incorrect")
Label4.Text = counter
Exit for
End If
Next
End Sub
Sub wordGeneration()
Dim wordUsed As Array = {"pizza", "noodle", "zombie", "object", "rowin", "running", "elephant", "lion"}
Dim random As New Random
randomWord = wordUsed(random.Next(0, 9))
Label2.Text = randomWord
End Sub
randomWord.Contains(ユーザ入力)するとなら... – soohoonigan
は働いたが、今では「正しい」繰り返していること8どのように私はそれを一度だけ言うことができますか? – Nugs
あなたのループはまだありますが、もう必要ありません。 letterInput()にはその中のif/else文が1つだけ必要です – soohoonigan