I am making a connect four game to learn some VBA.
I have an unbound form with buttons for the game pieces (tokens). An option group to pick which column to drop the token. A textbox (hidden) that represents which row the token is to be dropped on.
If I manually input a number in the textbox then hit the Drop Button it works as intended. Fills in the token and adds one to the correct textbox.
Example:
Put a 1 in to txtR1 hit drop button.
Token is filled in and txtR1 now shows 2, hit the drop button again and nothing. If I manually put a 2 in txtR1 then it works as intended.
Is the txtbox not updated when it shows it is?
I arranged the code str and row in the if statement and tried adding save in there and refresh.
Private Sub drop()
Dim Token As Control
Dim Row As Control
Dim r As Integer
Dim c As Integer
Dim str As String
c = Me.frmCol
str = "txtR" & c
Set Row = Me(str)
r = Row
For Each Token In Controls
If InStr(Token.Tag, "C" & c) Then
If Right(Token.name, 1) = Row Then
Token.BackStyle = 1
Token.BackColor = vbBlue
Row = r + 1
Exit Sub
End If
End If
Next Token
End Sub
