我已正确写出所有模式代码,但是在程序运行时它确实可以在程序中运行!我不知道这里的问题,我希望VB.net上的专家能帮上忙,因为我一生只参加了一门编程课...
对于任何想知道的人来说,这都是一个井字游戏。
我已经尝试了在这里和其他网站上看到的所有内容。
此外,代码的重点是,当某人获胜时,应该显示一个消息框,说他们赢了,然后在左上方或右上方的文本框中添加1。
这是来自form_load的一些代码
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'Generate Random Start
If TurnResult = 1 Then
lblPlayerTurn.Text = "Red Player's Turn"
End If
If TurnResult = 2 Then
lblPlayerTurn.Text = "Blue Player's Turn"
End If
'Blue Winners
If btn1.Text = "X" And btn5.Text = "X" And btn9.Text = "X" Then
MsgBox("Blue Player Wins!")
txtBlue.Text += 1
btn1.Enabled = False
btn2.Enabled = False
btn3.Enabled = False
btn4.Enabled = False
btn5.Enabled = False
btn6.Enabled = False
btn7.Enabled = False
btn8.Enabled = False
btn9.Enabled = False
End If
If btn1.Text = "X" And btn2.Text = "X" And btn3.Text = "X" Then
MsgBox("Blue Player Wins!")
txtBlue.Text += 1
btn1.Enabled = False
btn2.Enabled = False
btn3.Enabled = False
btn4.Enabled = False
btn5.Enabled = False
btn6.Enabled = False
btn7.Enabled = False
btn8.Enabled = False
btn9.Enabled = False
End If
If btn4.Text = "X" And btn5.Text = "X" And btn6.Text = "X" Then
MsgBox("Blue Player Wins!")
txtBlue.Text += 1
btn1.Enabled = False
btn2.Enabled = False
btn3.Enabled = False
btn4.Enabled = False
btn5.Enabled = False
btn6.Enabled = False
btn7.Enabled = False
btn8.Enabled = False
btn9.Enabled = False
End If
If btn7.Text = "X" And btn8.Text = "X" And btn9.Text = "X" Then
MsgBox("Blue Player Wins!")
txtBlue.Text += 1
btn1.Enabled = False
btn2.Enabled = False
btn3.Enabled = False
btn4.Enabled = False
btn5.Enabled = False
btn6.Enabled = False
btn7.Enabled = False
btn8.Enabled = False
btn9.Enabled = False
End If
If btn1.Text = "X" And btn4.Text = "X" And btn7.Text = "X" Then
MsgBox("Blue Player Wins!")
txtBlue.Text += 1
btn1.Enabled = False
btn2.Enabled = False
btn3.Enabled = False
btn4.Enabled = False
btn5.Enabled = False
btn6.Enabled = False
btn7.Enabled = False
btn8.Enabled = False
btn9.Enabled = False
End If