As i posted last night, i was making a game of tic-tac-toe.
Im pretty much done, i just dont know how to add a win check. Once i get that ill make it winsock for online fun ; )..Heres the code:
VB Code:
Option Explicit Dim x, y As Integer Dim teamname, compname As String Private Sub Form_Load() Call Restart1 End Sub Private Sub Restart_Click() Call Restart1 End Sub Private Sub xolbl_Click(Index As Integer) If Len(xolbl(Index).Caption) > 0 Then Exit Sub Select Case teamname Case "x" xolbl(Index).Caption = "x" Case "o" xolbl(Index).Caption = "o" End Select Call rndfunc Call addblock End Sub Private Sub rndfunc() y = Int((8 * Rnd) + 1) ' MsgBox y End Sub Private Sub changeteams() Select Case teamname Case "x" compname = "o" Case "o" compname = "x" End Select If Len(xolbl(y)) > 0 Then Call rndfunc Call addblock End If End Sub Private Sub addblock() On Error GoTo errhndlr If Len(xolbl(y)) > 0 Then Call rndfunc Call changeteams Else Call changeteams xolbl(y) = compname End If xolbl(y) = compname Call Checkforwin errhndlr: If Len(Err.Description) > 0 Then MsgBox Err.Number & Err.Description & " Source " & Err.Source End If End Sub Private Sub Checkforwin() End Sub Private Sub Restart1() Dim i As Integer Randomize x = Int((2 * Rnd) + 1) If x = 2 Then teamname = "x" Else teamname = "o" End If For i = 0 To xolbl.UBound xolbl(i).Caption = vbNullString Next i You.Caption = "You = " & teamname End Sub
How do i check for three in a row?




Reply With Quote