0
我試圖做一個hang子手遊戲,並輸入「不正確的」,如果用戶選擇了錯誤的字母,但它會繼續重複,因爲randomWord
它從數組中選擇單詞我該如何阻止?如何停止消息框重複,因爲數組?
Sub wordGeneration()
Dim wordUsed As Array = {"pizza", "noodle", "zombie", "object", "rowin", "running", "elephant", "lion"}
Dim random As New Random
randomWord = wordUsed(random.Next(0, 8))
Label2.Text = randomWord
End Sub
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
End If
Next
End Sub
在'MessageBox.Show'之後添加'Exit For' ...這將打破循環的進一步執行。 – Codexer
您是否在'Label4.Text = counter'之後的'Exit For'之後? – Bugs
VB.NET不是VBA – Plutonix