【发布时间】:2014-09-03 19:08:14
【问题描述】:
我正在尝试使用 Visual Basic 创建一个井字游戏。按下按钮后,按钮应首先变为“O”,然后下一次按下应为“X”,但它似乎继续放置“O”。
Dim turn As Boolean
turn = True 'true = X turn, false = Y turn
Dim b As Button
b = DirectCast(sender, Button)
If (turn) Then
b.Text = "O"
Else
b.Text = "X"
turn = Not turn <<< This seems to not to be working...
b.Enabled = False
End If
【问题讨论】:
-
转身声明在哪里?在类或函数中?听起来它应该是一个类/表单变量,所以每次按下按钮时都不会重新创建它。
标签: vb.net