سورس بازی XO

Dim XOTest As Boolean
Dim EGame As Boolean
Public Sub NewGame()
  Dim I As Byte
   
  For I = 1 To 9
    L(I) = ""
  Next I
   
  XOTest = False
  PlayerName = "X"
  EGame = False
End Sub
Private Sub L_Click(Index As Integer)

  If L(Index) = "" Then
 
    If XOTest = False Then
      L(Index).ForeColor = vbRed
      L(Index).Caption = "X"
      PlayerName = "O"
      XOTest = True
    Else
      L(Index).ForeColor = vbBlue
      L(Index) = "O"
      PlayerName = "X"
      XOTest = False
    End If
   
  End If
 
  If L(1) <> "" Or L(2) <> "" Or L(3) <> "" Or L(4) <> "" Or L(5) <> "" Or L(6) <> "" Or L(7) <> "" Or L(8) <> "" Or L(9) <> "" Then
   
    If L(1) = L(2) And L(1) = L(3) And L(1) <> "" And L(2) <> "" And L(3) <> "" Then EGame = True

    If L(1) = L(4) And L(1) = L(7) And L(1) <> "" And L(4) <> "" And L(7) <> "" Then EGame = True
 
    If L(1) = L(5) And L(1) = L(9) And L(1) <> "" And L(5) <> "" And L(9) <> "" Then EGame = True
 
    If L(2) = L(5) And L(2) = L(8) And L(2) <> "" And L(5) <> "" And L(8) <> "" Then EGame = True
 
    If L(3) = L(6) And L(3) = L(9) And L(3) <> "" And L(6) <> "" And L(9) <> "" Then EGame = True
 
    If L(3) = L(5) And L(3) = L(7) And L(3) <> "" And L(7) <> "" And L(9) <> "" Then EGame = True
 
    If L(4) = L(5) And L(4) = L(6) And L(4) <> "" And L(5) <> "" And L(6) <> "" Then EGame = True
 
    If L(7) = L(8) And L(7) = L(9) And L(7) <> "" And L(8) <> "" And L(9) <> "" Then EGame = True
    
    If EGame = True Then
      MsgBox "Player " & L(Index) & " Win . Press Ok to New Game ", vbInformation, "End Game"
      NewGame
    End If
      
  End If
 
  If L(1) <> "" And L(2) <> "" And L(3) <> "" And L(4) <> "" And L(5) <> "" And L(6) <> "" And L(7) <> "" And L(8) <> "" And L(9) <> "" Then
    MsgBox "Game has Not Good Player . Press Ok to start New Game", vbCritical, "Bad Game"
    NewGame
  End If
 
End Sub

دانلود

/ 1 نظر / 57 بازدید

عالیه رفیق ممنونم