home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / formbe1r / frm1play.frm (.txt) next >
Encoding:
Visual Basic Form  |  1999-08-09  |  25.4 KB  |  811 lines

  1. VERSION 5.00
  2. Begin VB.Form frm1Player 
  3.    BackColor       =   &H00000000&
  4.    BorderStyle     =   1  'Fixed Single
  5.    Caption         =   "One Player Tic Tac Toe"
  6.    ClientHeight    =   2595
  7.    ClientLeft      =   45
  8.    ClientTop       =   345
  9.    ClientWidth     =   4200
  10.    ControlBox      =   0   'False
  11.    LinkTopic       =   "Form1"
  12.    MaxButton       =   0   'False
  13.    MinButton       =   0   'False
  14.    ScaleHeight     =   2595
  15.    ScaleWidth      =   4200
  16.    StartUpPosition =   3  'Windows Default
  17.    Begin VB.Timer Timer4 
  18.       Interval        =   1
  19.       Left            =   5640
  20.       Top             =   480
  21.    End
  22.    Begin VB.Timer Timer3 
  23.       Left            =   5640
  24.       Top             =   960
  25.    End
  26.    Begin VB.Timer Timer2 
  27.       Left            =   5040
  28.       Top             =   960
  29.    End
  30.    Begin VB.Timer Timer1 
  31.       Interval        =   1
  32.       Left            =   5040
  33.       Top             =   360
  34.    End
  35.    Begin VB.CommandButton Command1 
  36.       Caption         =   "New Game"
  37.       Height          =   375
  38.       Left            =   2760
  39.       TabIndex        =   1
  40.       Top             =   240
  41.       Width           =   975
  42.    End
  43.    Begin VB.CommandButton Command2 
  44.       Caption         =   "E&xit"
  45.       Height          =   375
  46.       Left            =   2760
  47.       TabIndex        =   0
  48.       Top             =   840
  49.       Width           =   975
  50.    End
  51.    Begin VB.Line Line6 
  52.       BorderColor     =   &H0000FFFF&
  53.       BorderWidth     =   4
  54.       X1              =   3240
  55.       X2              =   3240
  56.       Y1              =   1440
  57.       Y2              =   2520
  58.    End
  59.    Begin VB.Label Label1 
  60.       BackStyle       =   0  'Transparent
  61.       Caption         =   "0"
  62.       BeginProperty Font 
  63.          Name            =   "Comic Sans MS"
  64.          Size            =   9
  65.          Charset         =   0
  66.          Weight          =   400
  67.          Underline       =   0   'False
  68.          Italic          =   0   'False
  69.          Strikethrough   =   0   'False
  70.       EndProperty
  71.       ForeColor       =   &H000000FF&
  72.       Height          =   255
  73.       Index           =   3
  74.       Left            =   3360
  75.       TabIndex        =   16
  76.       Top             =   1800
  77.       Width           =   375
  78.    End
  79.    Begin VB.Label Label1 
  80.       BackStyle       =   0  'Transparent
  81.       Caption         =   "0"
  82.       BeginProperty Font 
  83.          Name            =   "Comic Sans MS"
  84.          Size            =   9
  85.          Charset         =   0
  86.          Weight          =   400
  87.          Underline       =   0   'False
  88.          Italic          =   0   'False
  89.          Strikethrough   =   0   'False
  90.       EndProperty
  91.       ForeColor       =   &H000000FF&
  92.       Height          =   255
  93.       Index           =   2
  94.       Left            =   2760
  95.       TabIndex        =   15
  96.       Top             =   1800
  97.       Width           =   375
  98.    End
  99.    Begin VB.Label Label1 
  100.       BackStyle       =   0  'Transparent
  101.       Caption         =   "Losses"
  102.       BeginProperty Font 
  103.          Name            =   "Comic Sans MS"
  104.          Size            =   9
  105.          Charset         =   0
  106.          Weight          =   400
  107.          Underline       =   0   'False
  108.          Italic          =   0   'False
  109.          Strikethrough   =   0   'False
  110.       EndProperty
  111.       ForeColor       =   &H000000FF&
  112.       Height          =   255
  113.       Index           =   1
  114.       Left            =   3360
  115.       TabIndex        =   14
  116.       Top             =   1440
  117.       Width           =   615
  118.    End
  119.    Begin VB.Label Label1 
  120.       BackStyle       =   0  'Transparent
  121.       Caption         =   "Wins"
  122.       BeginProperty Font 
  123.          Name            =   "Comic Sans MS"
  124.          Size            =   9
  125.          Charset         =   0
  126.          Weight          =   400
  127.          Underline       =   0   'False
  128.          Italic          =   0   'False
  129.          Strikethrough   =   0   'False
  130.       EndProperty
  131.       ForeColor       =   &H000000FF&
  132.       Height          =   255
  133.       Index           =   0
  134.       Left            =   2640
  135.       TabIndex        =   13
  136.       Top             =   1440
  137.       Width           =   495
  138.    End
  139.    Begin VB.Label lblnum 
  140.       Caption         =   "1"
  141.       Height          =   255
  142.       Left            =   5640
  143.       TabIndex        =   12
  144.       Top             =   360
  145.       Visible         =   0   'False
  146.       Width           =   615
  147.    End
  148.    Begin VB.Label turn 
  149.       BackColor       =   &H00000000&
  150.       BackStyle       =   0  'Transparent
  151.       ForeColor       =   &H000000FF&
  152.       Height          =   615
  153.       Left            =   4920
  154.       TabIndex        =   11
  155.       Top             =   600
  156.       Width           =   615
  157.    End
  158.    Begin VB.Line Line1 
  159.       BorderColor     =   &H000000FF&
  160.       BorderWidth     =   4
  161.       X1              =   840
  162.       X2              =   840
  163.       Y1              =   120
  164.       Y2              =   2400
  165.    End
  166.    Begin VB.Line Line2 
  167.       BorderColor     =   &H000000FF&
  168.       BorderWidth     =   4
  169.       X1              =   1680
  170.       X2              =   1680
  171.       Y1              =   120
  172.       Y2              =   2400
  173.    End
  174.    Begin VB.Line Line3 
  175.       BorderColor     =   &H000000FF&
  176.       BorderWidth     =   4
  177.       X1              =   120
  178.       X2              =   2400
  179.       Y1              =   840
  180.       Y2              =   840
  181.    End
  182.    Begin VB.Line Line4 
  183.       BorderColor     =   &H000000FF&
  184.       BorderWidth     =   4
  185.       X1              =   120
  186.       X2              =   2400
  187.       Y1              =   1680
  188.       Y2              =   1680
  189.    End
  190.    Begin VB.Label s 
  191.       BackColor       =   &H00000000&
  192.       BackStyle       =   0  'Transparent
  193.       BeginProperty Font 
  194.          Name            =   "MS Sans Serif"
  195.          Size            =   24
  196.          Charset         =   0
  197.          Weight          =   400
  198.          Underline       =   0   'False
  199.          Italic          =   0   'False
  200.          Strikethrough   =   0   'False
  201.       EndProperty
  202.       ForeColor       =   &H00C00000&
  203.       Height          =   615
  204.       Index           =   0
  205.       Left            =   240
  206.       TabIndex        =   10
  207.       Top             =   120
  208.       Width           =   615
  209.    End
  210.    Begin VB.Label s 
  211.       BackColor       =   &H00000000&
  212.       BackStyle       =   0  'Transparent
  213.       BeginProperty Font 
  214.          Name            =   "MS Sans Serif"
  215.          Size            =   24
  216.          Charset         =   0
  217.          Weight          =   400
  218.          Underline       =   0   'False
  219.          Italic          =   0   'False
  220.          Strikethrough   =   0   'False
  221.       EndProperty
  222.       ForeColor       =   &H00C00000&
  223.       Height          =   615
  224.       Index           =   1
  225.       Left            =   1080
  226.       TabIndex        =   9
  227.       Top             =   120
  228.       Width           =   615
  229.    End
  230.    Begin VB.Label s 
  231.       BackColor       =   &H00000000&
  232.       BackStyle       =   0  'Transparent
  233.       BeginProperty Font 
  234.          Name            =   "MS Sans Serif"
  235.          Size            =   24
  236.          Charset         =   0
  237.          Weight          =   400
  238.          Underline       =   0   'False
  239.          Italic          =   0   'False
  240.          Strikethrough   =   0   'False
  241.       EndProperty
  242.       ForeColor       =   &H00C00000&
  243.       Height          =   615
  244.       Index           =   2
  245.       Left            =   1800
  246.       TabIndex        =   8
  247.       Top             =   120
  248.       Width           =   615
  249.    End
  250.    Begin VB.Label s 
  251.       BackColor       =   &H00000000&
  252.       BackStyle       =   0  'Transparent
  253.       BeginProperty Font 
  254.          Name            =   "MS Sans Serif"
  255.          Size            =   24
  256.          Charset         =   0
  257.          Weight          =   400
  258.          Underline       =   0   'False
  259.          Italic          =   0   'False
  260.          Strikethrough   =   0   'False
  261.       EndProperty
  262.       ForeColor       =   &H00C00000&
  263.       Height          =   615
  264.       Index           =   3
  265.       Left            =   240
  266.       TabIndex        =   7
  267.       Top             =   960
  268.       Width           =   615
  269.    End
  270.    Begin VB.Label s 
  271.       BackColor       =   &H00000000&
  272.       BackStyle       =   0  'Transparent
  273.       BeginProperty Font 
  274.          Name            =   "MS Sans Serif"
  275.          Size            =   24
  276.          Charset         =   0
  277.          Weight          =   400
  278.          Underline       =   0   'False
  279.          Italic          =   0   'False
  280.          Strikethrough   =   0   'False
  281.       EndProperty
  282.       ForeColor       =   &H00C00000&
  283.       Height          =   615
  284.       Index           =   4
  285.       Left            =   1080
  286.       TabIndex        =   6
  287.       Top             =   960
  288.       Width           =   615
  289.    End
  290.    Begin VB.Label s 
  291.       BackColor       =   &H00000000&
  292.       BackStyle       =   0  'Transparent
  293.       BeginProperty Font 
  294.          Name            =   "MS Sans Serif"
  295.          Size            =   24
  296.          Charset         =   0
  297.          Weight          =   400
  298.          Underline       =   0   'False
  299.          Italic          =   0   'False
  300.          Strikethrough   =   0   'False
  301.       EndProperty
  302.       ForeColor       =   &H00C00000&
  303.       Height          =   615
  304.       Index           =   5
  305.       Left            =   1800
  306.       TabIndex        =   5
  307.       Top             =   960
  308.       Width           =   615
  309.    End
  310.    Begin VB.Label s 
  311.       BackColor       =   &H00000000&
  312.       BackStyle       =   0  'Transparent
  313.       BeginProperty Font 
  314.          Name            =   "MS Sans Serif"
  315.          Size            =   24
  316.          Charset         =   0
  317.          Weight          =   400
  318.          Underline       =   0   'False
  319.          Italic          =   0   'False
  320.          Strikethrough   =   0   'False
  321.       EndProperty
  322.       ForeColor       =   &H00C00000&
  323.       Height          =   615
  324.       Index           =   6
  325.       Left            =   240
  326.       TabIndex        =   4
  327.       Top             =   1800
  328.       Width           =   615
  329.    End
  330.    Begin VB.Label s 
  331.       BackColor       =   &H00000000&
  332.       BackStyle       =   0  'Transparent
  333.       BeginProperty Font 
  334.          Name            =   "MS Sans Serif"
  335.          Size            =   24
  336.          Charset         =   0
  337.          Weight          =   400
  338.          Underline       =   0   'False
  339.          Italic          =   0   'False
  340.          Strikethrough   =   0   'False
  341.       EndProperty
  342.       ForeColor       =   &H00C00000&
  343.       Height          =   615
  344.       Index           =   7
  345.       Left            =   1080
  346.       TabIndex        =   3
  347.       Top             =   1800
  348.       Width           =   615
  349.    End
  350.    Begin VB.Label s 
  351.       BackColor       =   &H00000000&
  352.       BackStyle       =   0  'Transparent
  353.       BeginProperty Font 
  354.          Name            =   "MS Sans Serif"
  355.          Size            =   24
  356.          Charset         =   0
  357.          Weight          =   400
  358.          Underline       =   0   'False
  359.          Italic          =   0   'False
  360.          Strikethrough   =   0   'False
  361.       EndProperty
  362.       ForeColor       =   &H00C00000&
  363.       Height          =   615
  364.       Index           =   8
  365.       Left            =   1800
  366.       TabIndex        =   2
  367.       Top             =   1800
  368.       Width           =   615
  369.    End
  370.    Begin VB.Line Line5 
  371.       BorderColor     =   &H0000FFFF&
  372.       BorderWidth     =   4
  373.       Index           =   0
  374.       X1              =   120
  375.       X2              =   2400
  376.       Y1              =   360
  377.       Y2              =   360
  378.    End
  379.    Begin VB.Line Line5 
  380.       BorderColor     =   &H0000FFFF&
  381.       BorderWidth     =   4
  382.       Index           =   1
  383.       X1              =   120
  384.       X2              =   2400
  385.       Y1              =   1200
  386.       Y2              =   1200
  387.    End
  388.    Begin VB.Line Line5 
  389.       BorderColor     =   &H0000FFFF&
  390.       BorderWidth     =   4
  391.       Index           =   2
  392.       X1              =   120
  393.       X2              =   2400
  394.       Y1              =   2160
  395.       Y2              =   2160
  396.    End
  397.    Begin VB.Line Line5 
  398.       BorderColor     =   &H0000FFFF&
  399.       BorderWidth     =   4
  400.       Index           =   3
  401.       X1              =   360
  402.       X2              =   360
  403.       Y1              =   120
  404.       Y2              =   2400
  405.    End
  406.    Begin VB.Line Line5 
  407.       BorderColor     =   &H0000FFFF&
  408.       BorderWidth     =   4
  409.       Index           =   4
  410.       X1              =   1200
  411.       X2              =   1200
  412.       Y1              =   120
  413.       Y2              =   2400
  414.    End
  415.    Begin VB.Line Line5 
  416.       BorderColor     =   &H0000FFFF&
  417.       BorderWidth     =   4
  418.       Index           =   5
  419.       X1              =   1920
  420.       X2              =   1920
  421.       Y1              =   120
  422.       Y2              =   2400
  423.    End
  424.    Begin VB.Line Line5 
  425.       BorderColor     =   &H0000FFFF&
  426.       BorderWidth     =   4
  427.       Index           =   6
  428.       X1              =   240
  429.       X2              =   2280
  430.       Y1              =   240
  431.       Y2              =   2280
  432.    End
  433.    Begin VB.Line Line5 
  434.       BorderColor     =   &H0000FFFF&
  435.       BorderWidth     =   4
  436.       Index           =   7
  437.       X1              =   120
  438.       X2              =   2280
  439.       Y1              =   2280
  440.       Y2              =   120
  441.    End
  442. Attribute VB_Name = "frm1Player"
  443. Attribute VB_GlobalNameSpace = False
  444. Attribute VB_Creatable = False
  445. Attribute VB_PredeclaredId = True
  446. Attribute VB_Exposed = False
  447. Dim iwon As Boolean
  448. Dim cwon As Boolean
  449. Dim tie As Boolean
  450. Private Sub Command1_Click()
  451. s(0).Caption = ""
  452. For Index = 1 To 8
  453.     num = num + 1
  454.     s(num).Caption = ""
  455. Next Index
  456. Line5(0).Visible = False
  457. For i = 1 To 7
  458.     x = x + 1
  459.     Line5(x).Visible = False
  460. Next i
  461. lblnum.Caption = 1
  462. Timer1.Interval = 1
  463. Timer2.Interval = 0
  464. Timer3.Interval = 0
  465. Timer4.Interval = 1
  466. cwon = False
  467. iwon = False
  468. tie = False
  469. turn.Caption = "X"
  470. End Sub
  471. Private Sub Command2_Click()
  472. Unload Me
  473. frmTTTMain.Show
  474. End Sub
  475. Private Sub Form_Load()
  476. turn.Caption = "X"
  477. Line5(0).Visible = False
  478. For c = 1 To 7
  479.     h = h + 1
  480.     Line5(h).Visible = False
  481. Next c
  482. End Sub
  483. Private Sub s_Click(y As Integer)
  484. If turn.Caption = "X" And s(y).Caption = "" And cwon = False And iwon = False And tie = False Then
  485. s(y).Caption = "X"
  486. turn.Caption = "O"
  487. Call check
  488. lblnum = Val(lblnum.Caption) + 2
  489. End If
  490. End Sub
  491. Private Sub Timer1_Timer()
  492. 'Checks to see if anyone has one
  493. If s(0).Caption = "X" And s(1).Caption = "X" And s(2).Caption = "X" Then
  494. iwon = True
  495. cwon = False
  496. tie = False
  497. Line5(0).Visible = True
  498. End If
  499. If s(3).Caption = "X" And s(4).Caption = "X" And s(5).Caption = "X" Then
  500. iwon = True
  501. cwon = False
  502. tie = False
  503. Line5(1).Visible = True
  504. End If
  505. If s(6).Caption = "X" And s(7).Caption = "X" And s(8).Caption = "X" Then
  506. iwon = True
  507. cwon = False
  508. tie = False
  509. Line5(2).Visible = True
  510. End If
  511. If s(0).Caption = "X" And s(3).Caption = "X" And s(6).Caption = "X" Then
  512. iwon = True
  513. cwon = False
  514. tie = False
  515. Line5(3).Visible = True
  516. End If
  517. If s(1).Caption = "X" And s(4).Caption = "X" And s(7).Caption = "X" Then
  518. iwon = True
  519. cwon = False
  520. tie = False
  521. Line5(4).Visible = True
  522. End If
  523. If s(2).Caption = "X" And s(5).Caption = "X" And s(8).Caption = "X" Then
  524. iwon = True
  525. cwon = False
  526. tie = False
  527. Line5(5).Visible = True
  528. End If
  529. If s(0).Caption = "X" And s(4).Caption = "X" And s(8).Caption = "X" Then
  530. iwon = True
  531. cwon = False
  532. tie = False
  533. Line5(6).Visible = True
  534. End If
  535. If s(2).Caption = "X" And s(4).Caption = "X" And s(6).Caption = "X" Then
  536. iwon = True
  537. cwon = False
  538. tie = False
  539. Line5(7).Visible = True
  540. End If
  541. If s(0).Caption = "O" And s(1).Caption = "O" And s(2).Caption = "O" Then
  542. iwon = False
  543. cwon = True
  544. tie = False
  545. Line5(0).Visible = True
  546. End If
  547. If s(3).Caption = "O" And s(4).Caption = "O" And s(5).Caption = "O" Then
  548. iwon = False
  549. cwon = True
  550. tie = False
  551. Line5(1).Visible = True
  552. End If
  553. If s(6).Caption = "O" And s(7).Caption = "O" And s(8).Caption = "O" Then
  554. iwon = False
  555. cwon = True
  556. tie = False
  557. Line5(2).Visible = True
  558. End If
  559. If s(0).Caption = "O" And s(3).Caption = "O" And s(6).Caption = "O" Then
  560. iwon = False
  561. cwon = True
  562. tie = False
  563. Line5(3).Visible = True
  564. End If
  565. If s(1).Caption = "O" And s(4).Caption = "O" And s(7).Caption = "O" Then
  566. iwon = False
  567. cwon = True
  568. tie = False
  569. Line5(4).Visible = True
  570. End If
  571. If s(2).Caption = "O" And s(5).Caption = "O" And s(8).Caption = "O" Then
  572. iwon = False
  573. cwon = True
  574. tie = False
  575. Line5(5).Visible = True
  576. End If
  577. If s(0).Caption = "O" And s(4).Caption = "O" And s(8).Caption = "O" Then
  578. iwon = False
  579. cwon = True
  580. tie = False
  581. Line5(6).Visible = True
  582. End If
  583. If s(2).Caption = "O" And s(4).Caption = "O" And s(6).Caption = "O" Then
  584. iwon = False
  585. cwon = True
  586. tie = False
  587. Line5(7).Visible = True
  588. End If
  589. If s(0) <> "" And s(1) <> "" And s(2) <> "" And s(3) <> "" And s(4) <> "" And s(5) <> "" And s(6) <> "" And s(7) <> "" And s(8) <> "" And cwon = False And iwon = False Then
  590. tie = True
  591. iwon = False
  592. cwon = False
  593. End If
  594. End Sub
  595. Private Sub Timer2_Timer()
  596. 'this is where the computer "thinks"
  597. If iwon = False And cwon = False And tie = False Then
  598. If turn.Caption = "O" And s(0).Caption = "X" And s(1).Caption = "X" And s(2).Caption = "" Or s(0).Caption = "O" And s(1).Caption = "O" And s(2).Caption = "" Then
  599. s(2).Caption = "O"
  600. turn.Caption = "X"
  601. Timer2.Interval = 0
  602. ElseIf turn.Caption = "O" And s(0).Caption = "X" And s(2).Caption = "X" And s(1).Caption = "" Or s(0).Caption = "O" And s(2).Caption = "O" And s(1).Caption = "" Then
  603. s(1).Caption = "O"
  604. turn.Caption = "X"
  605. Timer2.Interval = 0
  606. ElseIf turn.Caption = "O" And s(1).Caption = "X" And s(2).Caption = "X" And s(0).Caption = "" Or s(1).Caption = "O" And s(2).Caption = "O" And s(0).Caption = "" Then
  607. s(0).Caption = "O"
  608. turn.Caption = "X"
  609. Timer2.Interval = 0
  610. ElseIf turn.Caption = "O" And s(3).Caption = "X" And s(4).Caption = "X" And s(5).Caption = "" Or s(3).Caption = "O" And s(4).Caption = "O" And s(5).Caption = "" Then
  611. s(5).Caption = "O"
  612. turn.Caption = "X"
  613. Timer2.Interval = 0
  614. ElseIf turn.Caption = "O" And s(3).Caption = "X" And s(5).Caption = "X" And s(4).Caption = "" Or s(0).Caption = "O" And s(5).Caption = "O" And s(4).Caption = "" Then
  615. s(4).Caption = "O"
  616. turn.Caption = "X"
  617. Timer2.Interval = 0
  618. ElseIf turn.Caption = "O" And s(4).Caption = "X" And s(5).Caption = "X" And s(3).Caption = "" Or s(4).Caption = "O" And s(5).Caption = "O" And s(3).Caption = "" Then
  619. s(3).Caption = "O"
  620. turn.Caption = "X"
  621. Timer2.Interval = 0
  622. ElseIf turn.Caption = "O" And s(6).Caption = "X" And s(7).Caption = "X" And s(8).Caption = "" Or s(6).Caption = "O" And s(7).Caption = "O" And s(8).Caption = "" Then
  623. s(8).Caption = "O"
  624. turn.Caption = "X"
  625. Timer2.Interval = 0
  626. ElseIf turn.Caption = "O" And s(6).Caption = "X" And s(8).Caption = "X" And s(7).Caption = "" Or s(6).Caption = "O" And s(8).Caption = "O" And s(7).Caption = "" Then
  627. s(7).Caption = "O"
  628. turn.Caption = "X"
  629. Timer2.Interval = 0
  630. ElseIf turn.Caption = "O" And s(7).Caption = "X" And s(8).Caption = "X" And s(6).Caption = "" Or s(7).Caption = "O" And s(8).Caption = "O" And s(6).Caption = "" Then
  631. s(6).Caption = "O"
  632. turn.Caption = "X"
  633. Timer2.Interval = 0
  634. ElseIf turn.Caption = "O" And s(0).Caption = "X" And s(3).Caption = "X" And s(6).Caption = "" Or s(0).Caption = "O" And s(3).Caption = "O" And s(6).Caption = "" Then
  635. s(6).Caption = "O"
  636. turn.Caption = "X"
  637. Timer2.Interval = 0
  638. ElseIf turn.Caption = "O" And s(0).Caption = "X" And s(6).Caption = "X" And s(3).Caption = "" Or s(0).Caption = "O" And s(6).Caption = "O" And s(3).Caption = "" Then
  639. s(3).Caption = "O"
  640. turn.Caption = "X"
  641. Timer2.Interval = 0
  642. ElseIf turn.Caption = "O" And s(3).Caption = "X" And s(6).Caption = "X" And s(0).Caption = "" Or s(3).Caption = "O" And s(6).Caption = "O" And s(0).Caption = "" Then
  643. s(0).Caption = "O"
  644. turn.Caption = "X"
  645. Timer2.Interval = 0
  646. ElseIf turn.Caption = "O" And s(1).Caption = "X" And s(4).Caption = "X" And s(7).Caption = "" Or s(1).Caption = "O" And s(4).Caption = "O" And s(7).Caption = "" Then
  647. s(7).Caption = "O"
  648. turn.Caption = "X"
  649. Timer2.Interval = 0
  650. ElseIf turn.Caption = "O" And s(1).Caption = "X" And s(7).Caption = "X" And s(4).Caption = "" Or s(1).Caption = "O" And s(7).Caption = "O" And s(4).Caption = "" Then
  651. s(4).Caption = "O"
  652. turn.Caption = "X"
  653. Timer2.Interval = 0
  654. ElseIf turn.Caption = "O" And s(4).Caption = "X" And s(7).Caption = "X" And s(1).Caption = "" Or s(4).Caption = "O" And s(7).Caption = "O" And s(1).Caption = "" Then
  655. s(1).Caption = "O"
  656. turn.Caption = "X"
  657. Timer2.Interval = 0
  658. ElseIf turn.Caption = "O" And s(2).Caption = "X" And s(5).Caption = "X" And s(8).Caption = "" Or s(2).Caption = "O" And s(5).Caption = "O" And s(8).Caption = "" Then
  659. s(8).Caption = "O"
  660. turn.Caption = "X"
  661. Timer2.Interval = 0
  662. ElseIf turn.Caption = "O" And s(2).Caption = "X" And s(8).Caption = "X" And s(5).Caption = "" Or s(2).Caption = "O" And s(8).Caption = "O" And s(5).Caption = "" Then
  663. s(5).Caption = "O"
  664. turn.Caption = "X"
  665. Timer2.Interval = 0
  666. ElseIf turn.Caption = "O" And s(5).Caption = "X" And s(8).Caption = "X" And s(2).Caption = "" Or s(5).Caption = "O" And s(8).Caption = "O" And s(2).Caption = "" Then
  667. s(2).Caption = "O"
  668. turn.Caption = "X"
  669. Timer2.Interval = 0
  670. ElseIf turn.Caption = "O" And s(0).Caption = "X" And s(4).Caption = "X" And s(8).Caption = "" Or s(0).Caption = "O" And s(4).Caption = "O" And s(8).Caption = "" Then
  671. s(8).Caption = "O"
  672. turn.Caption = "X"
  673. Timer2.Interval = 0
  674. ElseIf turn.Caption = "O" And s(0).Caption = "X" And s(8).Caption = "X" And s(4).Caption = "" Or s(0).Caption = "O" And s(8).Caption = "O" And s(4).Caption = "" Then
  675. s(4).Caption = "O"
  676. turn.Caption = "X"
  677. Timer2.Interval = 0
  678. ElseIf turn.Caption = "O" And s(4).Caption = "X" And s(8).Caption = "X" And s(0).Caption = "" Or s(4).Caption = "O" And s(8).Caption = "O" And s(0).Caption = "" Then
  679. s(0).Caption = "O"
  680. turn.Caption = "X"
  681. Timer2.Interval = 0
  682. ElseIf turn.Caption = "O" And s(2).Caption = "X" And s(4).Caption = "X" And s(6).Caption = "" Or s(2).Caption = "O" And s(4).Caption = "O" And s(6).Caption = "" Then
  683. s(6).Caption = "O"
  684. turn.Caption = "X"
  685. Timer2.Interval = 0
  686. ElseIf turn.Caption = "O" And s(2).Caption = "X" And s(6).Caption = "X" And s(4).Caption = "" Or s(2).Caption = "O" And s(6).Caption = "O" And s(4).Caption = "" Then
  687. s(4).Caption = "O"
  688. turn.Caption = "X"
  689. Timer2.Interval = 0
  690. Else:
  691. Timer2.Interval = 0
  692. Timer3.Interval = 1
  693. End If
  694. End If
  695. End Sub
  696. Private Sub check()
  697. If lblnum.Caption < 4 Then
  698. Timer3.Interval = 1
  699. End If
  700. If lblnum.Caption >= 5 Then
  701. Timer2.Interval = 1
  702. End If
  703. End Sub
  704. Private Sub Timer3_Timer()
  705. choose:
  706. Randomize
  707. x = Int(Rnd * 9) + 1
  708. Select Case x
  709.     Case 1
  710.         If s(0).Caption = "" Then
  711.             s(0).Caption = "O"
  712.         turn.Caption = "X"
  713.         Timer3.Interval = 0
  714.         ElseIf s(0).Caption = "X" Or s(0).Caption = "O" Then
  715.         GoTo choose
  716.         End If
  717.     Case 2
  718.         If s(1).Caption = "" Then
  719.            s(1).Caption = "O"
  720.            turn.Caption = "X"
  721.         Timer3.Interval = 0
  722.         ElseIf s(1).Caption = "X" Or s(1).Caption = "O" Then
  723.         GoTo choose
  724.         End If
  725.     Case 3
  726.         If s(2).Caption = "" Then
  727.            s(2).Caption = "O"
  728.            turn.Caption = "X"
  729.         Timer3.Interval = 0
  730.         ElseIf s(2).Caption = "X" Or s(2).Caption = "O" Then
  731.         GoTo choose
  732.         End If
  733.     Case 4
  734.         If s(3).Caption = "" Then
  735.            s(3).Caption = "O"
  736.            turn.Caption = "X"
  737.         Timer3.Interval = 0
  738.         ElseIf s(3).Caption = "X" Or s(3).Caption = "O" Then
  739.         GoTo choose
  740.         End If
  741.     Case 5
  742.         If s(4).Caption = "" Then
  743.            s(4).Caption = "O"
  744.            turn.Caption = "X"
  745.         Timer3.Interval = 0
  746.         ElseIf s(4).Caption = "X" Or s(4).Caption = "O" Then
  747.         GoTo choose
  748.         End If
  749.     Case 6
  750.         If s(5).Caption = "" Then
  751.            s(5).Caption = "O"
  752.            turn.Caption = "X"
  753.         Timer3.Interval = 0
  754.         ElseIf s(5).Caption = "X" Or s(5).Caption = "O" Then
  755.         GoTo choose
  756.         End If
  757.     Case 7
  758.         If s(6).Caption = "" Then
  759.            s(6).Caption = "O"
  760.            turn.Caption = "X"
  761.         Timer3.Interval = 0
  762.         ElseIf s(6).Caption = "X" Or s(6).Caption = "O" Then
  763.         GoTo choose
  764.         End If
  765.     Case 8
  766.         If s(7).Caption = "" Then
  767.            s(7).Caption = "O"
  768.            turn.Caption = "X"
  769.         Timer3.Interval = 0
  770.         ElseIf s(7).Caption = "X" Or s(7).Caption = "O" Then
  771.         GoTo choose
  772.         End If
  773.     Case 9
  774.         If s(8).Caption = "" Then
  775.            s(8).Caption = "O"
  776.            turn.Caption = "X"
  777.         Timer3.Interval = 0
  778.         ElseIf s(8).Caption = "X" Or s(8).Caption = "O" Then
  779.         GoTo choose
  780.         End If
  781. End Select
  782. End Sub
  783. Private Sub Timer4_Timer()
  784. If cwon = True Then
  785. Timer1.Interval = 0
  786. Timer2.Interval = 0
  787. Timer3.Interval = 0
  788. Timer4.Interval = 0
  789. lost = MsgBox("The computer beat you!", vbExclamation, "Tic Tac Toe")
  790. Label1(3).Caption = Val(Label1(3)) + 1
  791. turn.Caption = ""
  792. End If
  793. If iwon = True Then
  794. Timer1.Interval = 0
  795. Timer2.Interval = 0
  796. Timer3.Interval = 0
  797. Timer4.Interval = 0
  798. win = MsgBox("You Beat the computer!", vbExclamation, "Tic Tac Toe")
  799. Label1(2).Caption = Val(Label1(2)) + 1
  800. turn.Caption = ""
  801. End If
  802. If tie = True Then
  803. Timer1.Interval = 0
  804. Timer2.Interval = 0
  805. Timer3.Interval = 0
  806. Timer4.Interval = 0
  807. atie = MsgBox("There is no winner.  The game is a tie!", vbExclamation, "Tic Tac Toe")
  808. turn.Caption = ""
  809. End If
  810. End Sub
  811.