Hello.
I am trying to create a simple tic-tac-toe game as a learning experience. I am stuck on getting the computer to play "his turn."
What I am trying to do is create a random number, and then loop through all of the buttons on the form that are empty, counting each empty button until the count has reached the random number. Here is an example:
I have done some debug.writeline and it appears that the "count" variable is not increasing. I'm not sure if i have the for structured incorrectly, or what.
Thank you.
I am trying to create a simple tic-tac-toe game as a learning experience. I am stuck on getting the computer to play "his turn."
What I am trying to do is create a random number, and then loop through all of the buttons on the form that are empty, counting each empty button until the count has reached the random number. Here is an example:
Code:
dim rdm as new random()
dim targetnumber as integer
dim count as integer = 0
dim buttons as Control
targetnumber = rdm.next(10,100)
While count < targetnumber
For each buttons in Me.controls
If type(buttons) is Button then
If buttons.text = "" then
count +=1
If count = targetnumber thne
buttons.text="O"
Exit for
End if
End If
End If
Next
End While
I have done some debug.writeline and it appears that the "count" variable is not increasing. I'm not sure if i have the for structured incorrectly, or what.
Thank you.