Advertisement
Guest User

tic tac toe vb2010

a guest
Aug 21st, 2013
587
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Public Class Form2
  2.    
  3.  
  4.  
  5.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  6.         If turn.Text = "X" Then
  7.             Button1.Text = "X"
  8.             turn.Text = "O"
  9.         Else
  10.             Button1.Text = "O"
  11.             turn.Text = "X"
  12.         End If
  13.         Button1.Enabled = False
  14.  
  15.  
  16.  
  17.         'player X wins
  18.  
  19.         If Button1.Text = "X" And Button2.Text = "X" And Button3.Text = "X" Then
  20.             MsgBox("Player X Won!")
  21.             scoreX.Text = Val(scoreX.Text) + 1
  22.  
  23.  
  24.         End If
  25.         If Button4.Text = "X" And Button5.Text = "X" And Button6.Text = "X" Then
  26.             MsgBox("Player X Won!")
  27.             scoreX.Text = Val(scoreX.Text) + 1
  28.  
  29.         End If
  30.         If Button7.Text = "X" And Button8.Text = "X" And Button9.Text = "X" Then
  31.             MsgBox("Player X Won!")
  32.             scoreX.Text = Val(scoreX.Text) + 1
  33.  
  34.         End If
  35.         If Button1.Text = "X" And Button4.Text = "X" And Button7.Text = "X" Then
  36.             MsgBox("Player X Won!")
  37.             scoreX.Text = Val(scoreX.Text) + 1
  38.  
  39.         End If
  40.         If Button2.Text = "X" And Button5.Text = "X" And Button8.Text = "X" Then
  41.             MsgBox("Player X Won!")
  42.             scoreX.Text = Val(scoreX.Text) + 1
  43.  
  44.         End If
  45.         If Button3.Text = "X" And Button6.Text = "X" And Button9.Text = "X" Then
  46.             MsgBox("Player X Won!")
  47.             scoreX.Text = Val(scoreX.Text) + 1
  48.  
  49.         End If
  50.         If Button1.Text = "X" And Button5.Text = "X" And Button9.Text = "X" Then
  51.             MsgBox("Player X Won!")
  52.             scoreX.Text = Val(scoreX.Text) + 1
  53.  
  54.         End If
  55.         If Button3.Text = "X" And Button5.Text = "X" And Button7.Text = "X" Then
  56.             MsgBox("Player X Won!")
  57.             scoreX.Text = Val(scoreX.Text) + 1
  58.  
  59.         End If
  60.  
  61.  
  62.         'player O wins
  63.  
  64.         If Button1.Text = "O" And Button2.Text = "O" And Button3.Text = "O" Then
  65.             MsgBox("Player O Won!")
  66.             scoreO.Text = Val(scoreX.Text) + 1
  67.  
  68.         End If
  69.         If Button4.Text = "O" And Button5.Text = "O" And Button6.Text = "O" Then
  70.             MsgBox("Player O Won!")
  71.             scoreO.Text = Val(scoreX.Text) + 1
  72.  
  73.         End If
  74.         If Button7.Text = "O" And Button8.Text = "O" And Button9.Text = "O" Then
  75.             MsgBox("Player O Won!")
  76.             scoreO.Text = Val(scoreX.Text) + 1
  77.  
  78.         End If
  79.         If Button1.Text = "O" And Button4.Text = "O" And Button7.Text = "O" Then
  80.             MsgBox("Player O Won!")
  81.             scoreO.Text = Val(scoreX.Text) + 1
  82.  
  83.         End If
  84.         If Button2.Text = "O" And Button5.Text = "O" And Button8.Text = "O" Then
  85.             MsgBox("Player O Won!")
  86.             scoreO.Text = Val(scoreX.Text) + 1
  87.  
  88.         End If
  89.         If Button3.Text = "O" And Button6.Text = "O" And Button9.Text = "O" Then
  90.             MsgBox("Player O Won!")
  91.             scoreO.Text = Val(scoreX.Text) + 1
  92.  
  93.         End If
  94.         If Button1.Text = "O" And Button5.Text = "O" And Button9.Text = "O" Then
  95.             MsgBox("Player O Won!")
  96.             scoreO.Text = Val(scoreX.Text) + 1
  97.  
  98.         End If
  99.         If Button3.Text = "O" And Button5.Text = "O" And Button7.Text = "O" Then
  100.             MsgBox("Player O Won!")
  101.             scoreO.Text = Val(scoreX.Text) + 1
  102.  
  103.         End If
  104.  
  105.         If Button1.Enabled = False And Button2.Enabled = False And Button3.Enabled = False And Button4.Enabled = False _
  106. And Button5.Enabled = False And Button6.Enabled = False And Button7.Enabled = False And Button8.Enabled = False _
  107. And Button9.Enabled = False Then MsgBox("Its draw!!!")
  108.  
  109.  
  110.     End Sub
  111.  
  112.     Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
  113.         If turn.Text = "X" Then
  114.             Button2.Text = "X"
  115.             turn.Text = "O"
  116.         Else
  117.             Button2.Text = "O"
  118.             turn.Text = "X"
  119.         End If
  120.         Button2.Enabled = False
  121.  
  122.  
  123.  
  124.         'player X wins
  125.  
  126.         If Button1.Text = "X" And Button2.Text = "X" And Button3.Text = "X" Then
  127.             MsgBox("Player X Won!")
  128.             scoreX.Text = Val(scoreX.Text) + 1
  129.  
  130.         End If
  131.         If Button4.Text = "X" And Button5.Text = "X" And Button6.Text = "X" Then
  132.             MsgBox("Player X Won!")
  133.             scoreX.Text = Val(scoreX.Text) + 1
  134.  
  135.         End If
  136.         If Button7.Text = "X" And Button8.Text = "X" And Button9.Text = "X" Then
  137.             MsgBox("Player X Won!")
  138.             scoreX.Text = Val(scoreX.Text) + 1
  139.  
  140.         End If
  141.         If Button1.Text = "X" And Button4.Text = "X" And Button7.Text = "X" Then
  142.             MsgBox("Player X Won!")
  143.             scoreX.Text = Val(scoreX.Text) + 1
  144.  
  145.         End If
  146.         If Button2.Text = "X" And Button5.Text = "X" And Button8.Text = "X" Then
  147.             MsgBox("Player X Won!")
  148.             scoreX.Text = Val(scoreX.Text) + 1
  149.  
  150.         End If
  151.         If Button3.Text = "X" And Button6.Text = "X" And Button9.Text = "X" Then
  152.             MsgBox("Player X Won!")
  153.             scoreX.Text = Val(scoreX.Text) + 1
  154.  
  155.         End If
  156.         If Button1.Text = "X" And Button5.Text = "X" And Button9.Text = "X" Then
  157.             MsgBox("Player X Won!")
  158.             scoreX.Text = Val(scoreX.Text) + 1
  159.  
  160.         End If
  161.         If Button3.Text = "X" And Button5.Text = "X" And Button7.Text = "X" Then
  162.             MsgBox("Player X Won!")
  163.             scoreX.Text = Val(scoreX.Text) + 1
  164.  
  165.         End If
  166.  
  167.  
  168.         'player O wins
  169.  
  170.         If Button1.Text = "O" And Button2.Text = "O" And Button3.Text = "O" Then
  171.             MsgBox("Player O Won!")
  172.             scoreO.Text = Val(scoreX.Text) + 1
  173.  
  174.         End If
  175.         If Button4.Text = "O" And Button5.Text = "O" And Button6.Text = "O" Then
  176.             MsgBox("Player O Won!")
  177.             scoreO.Text = Val(scoreX.Text) + 1
  178.  
  179.         End If
  180.         If Button7.Text = "O" And Button8.Text = "O" And Button9.Text = "O" Then
  181.             MsgBox("Player O Won!")
  182.             scoreO.Text = Val(scoreX.Text) + 1
  183.  
  184.         End If
  185.         If Button1.Text = "O" And Button4.Text = "O" And Button7.Text = "O" Then
  186.             MsgBox("Player O Won!")
  187.             scoreO.Text = Val(scoreX.Text) + 1
  188.  
  189.         End If
  190.         If Button2.Text = "O" And Button5.Text = "O" And Button8.Text = "O" Then
  191.             MsgBox("Player O Won!")
  192.             scoreO.Text = Val(scoreX.Text) + 1
  193.  
  194.         End If
  195.         If Button3.Text = "O" And Button6.Text = "O" And Button9.Text = "O" Then
  196.             MsgBox("Player O Won!")
  197.             scoreO.Text = Val(scoreX.Text) + 1
  198.  
  199.         End If
  200.         If Button1.Text = "O" And Button5.Text = "O" And Button9.Text = "O" Then
  201.             MsgBox("Player O Won!")
  202.             scoreO.Text = Val(scoreX.Text) + 1
  203.  
  204.         End If
  205.         If Button3.Text = "O" And Button5.Text = "O" And Button7.Text = "O" Then
  206.             MsgBox("Player O Won!")
  207.             scoreO.Text = Val(scoreX.Text) + 1
  208.  
  209.         End If
  210.  
  211.  
  212.         If Button1.Enabled = False And Button2.Enabled = False And Button3.Enabled = False And Button4.Enabled = False _
  213. And Button5.Enabled = False And Button6.Enabled = False And Button7.Enabled = False And Button8.Enabled = False _
  214. And Button9.Enabled = False Then MsgBox("Its draw!!!")
  215.  
  216.     End Sub
  217.  
  218.     Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
  219.         If turn.Text = "X" Then
  220.             Button3.Text = "X"
  221.             turn.Text = "O"
  222.         Else
  223.             Button3.Text = "O"
  224.             turn.Text = "X"
  225.         End If
  226.         Button3.Enabled = False
  227.  
  228.  
  229.         'player X wins
  230.  
  231.         If Button1.Text = "X" And Button2.Text = "X" And Button3.Text = "X" Then
  232.             MsgBox("Player X Won!")
  233.             scoreX.Text = Val(scoreX.Text) + 1
  234.  
  235.         End If
  236.         If Button4.Text = "X" And Button5.Text = "X" And Button6.Text = "X" Then
  237.             MsgBox("Player X Won!")
  238.             scoreX.Text = Val(scoreX.Text) + 1
  239.  
  240.         End If
  241.         If Button7.Text = "X" And Button8.Text = "X" And Button9.Text = "X" Then
  242.             MsgBox("Player X Won!")
  243.             scoreX.Text = Val(scoreX.Text) + 1
  244.  
  245.         End If
  246.         If Button1.Text = "X" And Button4.Text = "X" And Button7.Text = "X" Then
  247.             MsgBox("Player X Won!")
  248.             scoreX.Text = Val(scoreX.Text) + 1
  249.  
  250.         End If
  251.         If Button2.Text = "X" And Button5.Text = "X" And Button8.Text = "X" Then
  252.             MsgBox("Player X Won!")
  253.             scoreX.Text = Val(scoreX.Text) + 1
  254.  
  255.         End If
  256.         If Button3.Text = "X" And Button6.Text = "X" And Button9.Text = "X" Then
  257.             MsgBox("Player X Won!")
  258.             scoreX.Text = Val(scoreX.Text) + 1
  259.  
  260.         End If
  261.         If Button1.Text = "X" And Button5.Text = "X" And Button9.Text = "X" Then
  262.             MsgBox("Player X Won!")
  263.             scoreX.Text = Val(scoreX.Text) + 1
  264.  
  265.         End If
  266.         If Button3.Text = "X" And Button5.Text = "X" And Button7.Text = "X" Then
  267.             MsgBox("Player X Won!")
  268.             scoreX.Text = Val(scoreX.Text) + 1
  269.  
  270.         End If
  271.  
  272.  
  273.         'player O wins
  274.  
  275.         If Button1.Text = "O" And Button2.Text = "O" And Button3.Text = "O" Then
  276.             MsgBox("Player O Won!")
  277.             scoreO.Text = Val(scoreX.Text) + 1
  278.  
  279.         End If
  280.         If Button4.Text = "O" And Button5.Text = "O" And Button6.Text = "O" Then
  281.             MsgBox("Player O Won!")
  282.             scoreO.Text = Val(scoreX.Text) + 1
  283.  
  284.         End If
  285.         If Button7.Text = "O" And Button8.Text = "O" And Button9.Text = "O" Then
  286.             MsgBox("Player O Won!")
  287.             scoreO.Text = Val(scoreX.Text) + 1
  288.  
  289.         End If
  290.         If Button1.Text = "O" And Button4.Text = "O" And Button7.Text = "O" Then
  291.             MsgBox("Player O Won!")
  292.             scoreO.Text = Val(scoreX.Text) + 1
  293.  
  294.         End If
  295.         If Button2.Text = "O" And Button5.Text = "O" And Button8.Text = "O" Then
  296.             MsgBox("Player O Won!")
  297.             scoreO.Text = Val(scoreX.Text) + 1
  298.  
  299.         End If
  300.         If Button3.Text = "O" And Button6.Text = "O" And Button9.Text = "O" Then
  301.             MsgBox("Player O Won!")
  302.             scoreO.Text = Val(scoreX.Text) + 1
  303.  
  304.         End If
  305.         If Button1.Text = "O" And Button5.Text = "O" And Button9.Text = "O" Then
  306.             MsgBox("Player O Won!")
  307.             scoreO.Text = Val(scoreX.Text) + 1
  308.  
  309.         End If
  310.         If Button3.Text = "O" And Button5.Text = "O" And Button7.Text = "O" Then
  311.             MsgBox("Player O Won!")
  312.             scoreO.Text = Val(scoreX.Text) + 1
  313.  
  314.         End If
  315.          If Button1.Enabled = False And Button2.Enabled = False And Button3.Enabled = False And Button4.Enabled = False _
  316. And Button5.Enabled = False And Button6.Enabled = False And Button7.Enabled = False And Button8.Enabled = False _
  317. And Button9.Enabled = False Then MsgBox("Its draw!!!")
  318.  
  319.  
  320.     End Sub
  321.  
  322.     Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
  323.         If turn.Text = "X" Then
  324.             Button4.Text = "X"
  325.             turn.Text = "O"
  326.         Else
  327.             Button4.Text = "O"
  328.             turn.Text = "X"
  329.         End If
  330.         Button4.Enabled = False
  331.  
  332.  
  333.         'player X wins
  334.  
  335.         If Button1.Text = "X" And Button2.Text = "X" And Button3.Text = "X" Then
  336.             MsgBox("Player X Won!")
  337.             scoreX.Text = Val(scoreX.Text) + 1
  338.  
  339.         End If
  340.         If Button4.Text = "X" And Button5.Text = "X" And Button6.Text = "X" Then
  341.             MsgBox("Player X Won!")
  342.             scoreX.Text = Val(scoreX.Text) + 1
  343.  
  344.         End If
  345.         If Button7.Text = "X" And Button8.Text = "X" And Button9.Text = "X" Then
  346.             MsgBox("Player X Won!")
  347.             scoreX.Text = Val(scoreX.Text) + 1
  348.  
  349.         End If
  350.         If Button1.Text = "X" And Button4.Text = "X" And Button7.Text = "X" Then
  351.             MsgBox("Player X Won!")
  352.             scoreX.Text = Val(scoreX.Text) + 1
  353.  
  354.         End If
  355.         If Button2.Text = "X" And Button5.Text = "X" And Button8.Text = "X" Then
  356.             MsgBox("Player X Won!")
  357.             scoreX.Text = Val(scoreX.Text) + 1
  358.  
  359.         End If
  360.         If Button3.Text = "X" And Button6.Text = "X" And Button9.Text = "X" Then
  361.             MsgBox("Player X Won!")
  362.             scoreX.Text = Val(scoreX.Text) + 1
  363.  
  364.         End If
  365.         If Button1.Text = "X" And Button5.Text = "X" And Button9.Text = "X" Then
  366.             MsgBox("Player X Won!")
  367.             scoreX.Text = Val(scoreX.Text) + 1
  368.  
  369.         End If
  370.         If Button3.Text = "X" And Button5.Text = "X" And Button7.Text = "X" Then
  371.             MsgBox("Player X Won!")
  372.             scoreX.Text = Val(scoreX.Text) + 1
  373.  
  374.         End If
  375.  
  376.  
  377.         'player O wins
  378.  
  379.         If Button1.Text = "O" And Button2.Text = "O" And Button3.Text = "O" Then
  380.             MsgBox("Player O Won!")
  381.             scoreO.Text = Val(scoreX.Text) + 1
  382.  
  383.         End If
  384.         If Button4.Text = "O" And Button5.Text = "O" And Button6.Text = "O" Then
  385.             MsgBox("Player O Won!")
  386.             scoreO.Text = Val(scoreX.Text) + 1
  387.  
  388.         End If
  389.         If Button7.Text = "O" And Button8.Text = "O" And Button9.Text = "O" Then
  390.             MsgBox("Player O Won!")
  391.             scoreO.Text = Val(scoreX.Text) + 1
  392.  
  393.         End If
  394.         If Button1.Text = "O" And Button4.Text = "O" And Button7.Text = "O" Then
  395.             MsgBox("Player O Won!")
  396.             scoreO.Text = Val(scoreX.Text) + 1
  397.  
  398.         End If
  399.         If Button2.Text = "O" And Button5.Text = "O" And Button8.Text = "O" Then
  400.             MsgBox("Player O Won!")
  401.             scoreO.Text = Val(scoreX.Text) + 1
  402.  
  403.         End If
  404.         If Button3.Text = "O" And Button6.Text = "O" And Button9.Text = "O" Then
  405.             MsgBox("Player O Won!")
  406.             scoreO.Text = Val(scoreX.Text) + 1
  407.  
  408.         End If
  409.         If Button1.Text = "O" And Button5.Text = "O" And Button9.Text = "O" Then
  410.             MsgBox("Player O Won!")
  411.             scoreO.Text = Val(scoreX.Text) + 1
  412.  
  413.         End If
  414.         If Button3.Text = "O" And Button5.Text = "O" And Button7.Text = "O" Then
  415.             MsgBox("Player O Won!")
  416.             scoreO.Text = Val(scoreX.Text) + 1
  417.  
  418.         End If
  419.          If Button1.Enabled = False And Button2.Enabled = False And Button3.Enabled = False And Button4.Enabled = False _
  420. And Button5.Enabled = False And Button6.Enabled = False And Button7.Enabled = False And Button8.Enabled = False _
  421. And Button9.Enabled = False Then MsgBox("Its draw!!!")
  422.  
  423.     End Sub
  424.  
  425.     Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
  426.         If turn.Text = "X" Then
  427.             Button5.Text = "X"
  428.             turn.Text = "O"
  429.         Else
  430.             Button5.Text = "O"
  431.             turn.Text = "X"
  432.         End If
  433.         Button5.Enabled = False
  434.  
  435.  
  436.         'player X wins
  437.  
  438.         If Button1.Text = "X" And Button2.Text = "X" And Button3.Text = "X" Then
  439.             MsgBox("Player X Won!")
  440.             scoreX.Text = Val(scoreX.Text) + 1
  441.  
  442.         End If
  443.         If Button4.Text = "X" And Button5.Text = "X" And Button6.Text = "X" Then
  444.             MsgBox("Player X Won!")
  445.             scoreX.Text = Val(scoreX.Text) + 1
  446.  
  447.         End If
  448.         If Button7.Text = "X" And Button8.Text = "X" And Button9.Text = "X" Then
  449.             MsgBox("Player X Won!")
  450.             scoreX.Text = Val(scoreX.Text) + 1
  451.  
  452.         End If
  453.         If Button1.Text = "X" And Button4.Text = "X" And Button7.Text = "X" Then
  454.             MsgBox("Player X Won!")
  455.             scoreX.Text = Val(scoreX.Text) + 1
  456.  
  457.         End If
  458.         If Button2.Text = "X" And Button5.Text = "X" And Button8.Text = "X" Then
  459.             MsgBox("Player X Won!")
  460.             scoreX.Text = Val(scoreX.Text) + 1
  461.  
  462.         End If
  463.         If Button3.Text = "X" And Button6.Text = "X" And Button9.Text = "X" Then
  464.             MsgBox("Player X Won!")
  465.             scoreX.Text = Val(scoreX.Text) + 1
  466.  
  467.         End If
  468.         If Button1.Text = "X" And Button5.Text = "X" And Button9.Text = "X" Then
  469.             MsgBox("Player X Won!")
  470.             scoreX.Text = Val(scoreX.Text) + 1
  471.  
  472.         End If
  473.         If Button3.Text = "X" And Button5.Text = "X" And Button7.Text = "X" Then
  474.             MsgBox("Player X Won!")
  475.             scoreX.Text = Val(scoreX.Text) + 1
  476.  
  477.         End If
  478.  
  479.  
  480.         'player O wins
  481.  
  482.         If Button1.Text = "O" And Button2.Text = "O" And Button3.Text = "O" Then
  483.             MsgBox("Player O Won!")
  484.             scoreO.Text = Val(scoreX.Text) + 1
  485.  
  486.         End If
  487.         If Button4.Text = "O" And Button5.Text = "O" And Button6.Text = "O" Then
  488.             MsgBox("Player O Won!")
  489.             scoreO.Text = Val(scoreX.Text) + 1
  490.  
  491.         End If
  492.         If Button7.Text = "O" And Button8.Text = "O" And Button9.Text = "O" Then
  493.             MsgBox("Player O Won!")
  494.             scoreO.Text = Val(scoreX.Text) + 1
  495.  
  496.         End If
  497.         If Button1.Text = "O" And Button4.Text = "O" And Button7.Text = "O" Then
  498.             MsgBox("Player O Won!")
  499.             scoreO.Text = Val(scoreX.Text) + 1
  500.  
  501.         End If
  502.         If Button2.Text = "O" And Button5.Text = "O" And Button8.Text = "O" Then
  503.             MsgBox("Player O Won!")
  504.             scoreO.Text = Val(scoreX.Text) + 1
  505.  
  506.         End If
  507.         If Button3.Text = "O" And Button6.Text = "O" And Button9.Text = "O" Then
  508.             MsgBox("Player O Won!")
  509.             scoreO.Text = Val(scoreX.Text) + 1
  510.  
  511.         End If
  512.         If Button1.Text = "O" And Button5.Text = "O" And Button9.Text = "O" Then
  513.             MsgBox("Player O Won!")
  514.             scoreO.Text = Val(scoreX.Text) + 1
  515.  
  516.         End If
  517.         If Button3.Text = "O" And Button5.Text = "O" And Button7.Text = "O" Then
  518.             MsgBox("Player O Won!")
  519.             scoreO.Text = Val(scoreX.Text) + 1
  520.  
  521.         End If
  522.         If Button1.Enabled = False And Button2.Enabled = False And Button3.Enabled = False And Button4.Enabled = False _
  523. And Button5.Enabled = False And Button6.Enabled = False And Button7.Enabled = False And Button8.Enabled = False _
  524. And Button9.Enabled = False Then MsgBox("Its draw!!!")
  525.  
  526.     End Sub
  527.  
  528.     Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
  529.         If turn.Text = "X" Then
  530.             Button6.Text = "X"
  531.             turn.Text = "O"
  532.         Else
  533.             Button6.Text = "O"
  534.             turn.Text = "X"
  535.         End If
  536.         Button6.Enabled = False
  537.  
  538.         'player X wins
  539.  
  540.         If Button1.Text = "X" And Button2.Text = "X" And Button3.Text = "X" Then
  541.             MsgBox("Player X Won!")
  542.             scoreX.Text = Val(scoreX.Text) + 1
  543.  
  544.         End If
  545.         If Button4.Text = "X" And Button5.Text = "X" And Button6.Text = "X" Then
  546.             MsgBox("Player X Won!")
  547.             scoreX.Text = Val(scoreX.Text) + 1
  548.  
  549.         End If
  550.         If Button7.Text = "X" And Button8.Text = "X" And Button9.Text = "X" Then
  551.             MsgBox("Player X Won!")
  552.             scoreX.Text = Val(scoreX.Text) + 1
  553.  
  554.         End If
  555.         If Button1.Text = "X" And Button4.Text = "X" And Button7.Text = "X" Then
  556.             MsgBox("Player X Won!")
  557.             scoreX.Text = Val(scoreX.Text) + 1
  558.  
  559.         End If
  560.         If Button2.Text = "X" And Button5.Text = "X" And Button8.Text = "X" Then
  561.             MsgBox("Player X Won!")
  562.             scoreX.Text = Val(scoreX.Text) + 1
  563.  
  564.         End If
  565.         If Button3.Text = "X" And Button6.Text = "X" And Button9.Text = "X" Then
  566.             MsgBox("Player X Won!")
  567.             scoreX.Text = Val(scoreX.Text) + 1
  568.  
  569.         End If
  570.         If Button1.Text = "X" And Button5.Text = "X" And Button9.Text = "X" Then
  571.             MsgBox("Player X Won!")
  572.             scoreX.Text = Val(scoreX.Text) + 1
  573.  
  574.         End If
  575.         If Button3.Text = "X" And Button5.Text = "X" And Button7.Text = "X" Then
  576.             MsgBox("Player X Won!")
  577.             scoreX.Text = Val(scoreX.Text) + 1
  578.  
  579.         End If
  580.  
  581.  
  582.         'player O wins
  583.  
  584.         If Button1.Text = "O" And Button2.Text = "O" And Button3.Text = "O" Then
  585.             MsgBox("Player O Won!")
  586.             scoreO.Text = Val(scoreX.Text) + 1
  587.  
  588.         End If
  589.         If Button4.Text = "O" And Button5.Text = "O" And Button6.Text = "O" Then
  590.             MsgBox("Player O Won!")
  591.             scoreO.Text = Val(scoreX.Text) + 1
  592.  
  593.         End If
  594.         If Button7.Text = "O" And Button8.Text = "O" And Button9.Text = "O" Then
  595.             MsgBox("Player O Won!")
  596.             scoreO.Text = Val(scoreX.Text) + 1
  597.  
  598.         End If
  599.         If Button1.Text = "O" And Button4.Text = "O" And Button7.Text = "O" Then
  600.             MsgBox("Player O Won!")
  601.             scoreO.Text = Val(scoreX.Text) + 1
  602.  
  603.         End If
  604.         If Button2.Text = "O" And Button5.Text = "O" And Button8.Text = "O" Then
  605.             MsgBox("Player O Won!")
  606.             scoreO.Text = Val(scoreX.Text) + 1
  607.  
  608.         End If
  609.         If Button3.Text = "O" And Button6.Text = "O" And Button9.Text = "O" Then
  610.             MsgBox("Player O Won!")
  611.             scoreO.Text = Val(scoreX.Text) + 1
  612.  
  613.         End If
  614.         If Button1.Text = "O" And Button5.Text = "O" And Button9.Text = "O" Then
  615.             MsgBox("Player O Won!")
  616.             scoreO.Text = Val(scoreX.Text) + 1
  617.  
  618.         End If
  619.         If Button3.Text = "O" And Button5.Text = "O" And Button7.Text = "O" Then
  620.             MsgBox("Player O Won!")
  621.             scoreO.Text = Val(scoreX.Text) + 1
  622.  
  623.         End If
  624.          If Button1.Enabled = False And Button2.Enabled = False And Button3.Enabled = False And Button4.Enabled = False _
  625. And Button5.Enabled = False And Button6.Enabled = False And Button7.Enabled = False And Button8.Enabled = False _
  626. And Button9.Enabled = False Then MsgBox("Its draw!!!")
  627.  
  628.     End Sub
  629.  
  630.     Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
  631.         If turn.Text = "X" Then
  632.             Button7.Text = "X"
  633.             turn.Text = "O"
  634.         Else
  635.             Button7.Text = "O"
  636.             turn.Text = "X"
  637.         End If
  638.         Button7.Enabled = False
  639.  
  640.         'player X wins
  641.  
  642.         If Button1.Text = "X" And Button2.Text = "X" And Button3.Text = "X" Then
  643.             MsgBox("Player X Won!")
  644.             scoreX.Text = Val(scoreX.Text) + 1
  645.  
  646.         End If
  647.         If Button4.Text = "X" And Button5.Text = "X" And Button6.Text = "X" Then
  648.             MsgBox("Player X Won!")
  649.             scoreX.Text = Val(scoreX.Text) + 1
  650.  
  651.         End If
  652.         If Button7.Text = "X" And Button8.Text = "X" And Button9.Text = "X" Then
  653.             MsgBox("Player X Won!")
  654.             scoreX.Text = Val(scoreX.Text) + 1
  655.  
  656.         End If
  657.         If Button1.Text = "X" And Button4.Text = "X" And Button7.Text = "X" Then
  658.             MsgBox("Player X Won!")
  659.             scoreX.Text = Val(scoreX.Text) + 1
  660.  
  661.         End If
  662.         If Button2.Text = "X" And Button5.Text = "X" And Button8.Text = "X" Then
  663.             MsgBox("Player X Won!")
  664.             scoreX.Text = Val(scoreX.Text) + 1
  665.  
  666.         End If
  667.         If Button3.Text = "X" And Button6.Text = "X" And Button9.Text = "X" Then
  668.             MsgBox("Player X Won!")
  669.             scoreX.Text = Val(scoreX.Text) + 1
  670.  
  671.         End If
  672.         If Button1.Text = "X" And Button5.Text = "X" And Button9.Text = "X" Then
  673.             MsgBox("Player X Won!")
  674.             scoreX.Text = Val(scoreX.Text) + 1
  675.  
  676.         End If
  677.         If Button3.Text = "X" And Button5.Text = "X" And Button7.Text = "X" Then
  678.             MsgBox("Player X Won!")
  679.             scoreX.Text = Val(scoreX.Text) + 1
  680.  
  681.         End If
  682.  
  683.  
  684.         'player O wins
  685.  
  686.         If Button1.Text = "O" And Button2.Text = "O" And Button3.Text = "O" Then
  687.             MsgBox("Player O Won!")
  688.             scoreO.Text = Val(scoreX.Text) + 1
  689.  
  690.         End If
  691.         If Button4.Text = "O" And Button5.Text = "O" And Button6.Text = "O" Then
  692.             MsgBox("Player O Won!")
  693.             scoreO.Text = Val(scoreX.Text) + 1
  694.  
  695.         End If
  696.         If Button7.Text = "O" And Button8.Text = "O" And Button9.Text = "O" Then
  697.             MsgBox("Player O Won!")
  698.             scoreO.Text = Val(scoreX.Text) + 1
  699.  
  700.         End If
  701.         If Button1.Text = "O" And Button4.Text = "O" And Button7.Text = "O" Then
  702.             MsgBox("Player O Won!")
  703.             scoreO.Text = Val(scoreX.Text) + 1
  704.  
  705.         End If
  706.         If Button2.Text = "O" And Button5.Text = "O" And Button8.Text = "O" Then
  707.             MsgBox("Player O Won!")
  708.             scoreO.Text = Val(scoreX.Text) + 1
  709.  
  710.         End If
  711.         If Button3.Text = "O" And Button6.Text = "O" And Button9.Text = "O" Then
  712.             MsgBox("Player O Won!")
  713.             scoreO.Text = Val(scoreX.Text) + 1
  714.  
  715.         End If
  716.         If Button1.Text = "O" And Button5.Text = "O" And Button9.Text = "O" Then
  717.             MsgBox("Player O Won!")
  718.             scoreO.Text = Val(scoreX.Text) + 1
  719.  
  720.         End If
  721.         If Button3.Text = "O" And Button5.Text = "O" And Button7.Text = "O" Then
  722.             MsgBox("Player O Won!")
  723.             scoreO.Text = Val(scoreX.Text) + 1
  724.  
  725.         End If
  726.       If Button1.Enabled = False And Button2.Enabled = False And Button3.Enabled = False And Button4.Enabled = False _
  727.   And Button5.Enabled = False And Button6.Enabled = False And Button7.Enabled = False And Button8.Enabled = False _
  728.   And Button9.Enabled = False Then MsgBox("Its draw!!!")
  729.  
  730.  
  731.     End Sub
  732.  
  733.     Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
  734.         If turn.Text = "X" Then
  735.             Button8.Text = "X"
  736.             turn.Text = "O"
  737.         Else
  738.             Button8.Text = "O"
  739.             turn.Text = "X"
  740.         End If
  741.         Button8.Enabled = False
  742.  
  743.         'player X wins
  744.  
  745.         If Button1.Text = "X" And Button2.Text = "X" And Button3.Text = "X" Then
  746.             MsgBox("Player X Won!")
  747.             scoreX.Text = Val(scoreX.Text) + 1
  748.  
  749.         End If
  750.         If Button4.Text = "X" And Button5.Text = "X" And Button6.Text = "X" Then
  751.             MsgBox("Player X Won!")
  752.             scoreX.Text = Val(scoreX.Text) + 1
  753.  
  754.         End If
  755.         If Button7.Text = "X" And Button8.Text = "X" And Button9.Text = "X" Then
  756.             MsgBox("Player X Won!")
  757.             scoreX.Text = Val(scoreX.Text) + 1
  758.  
  759.         End If
  760.         If Button1.Text = "X" And Button4.Text = "X" And Button7.Text = "X" Then
  761.             MsgBox("Player X Won!")
  762.             scoreX.Text = Val(scoreX.Text) + 1
  763.  
  764.         End If
  765.         If Button2.Text = "X" And Button5.Text = "X" And Button8.Text = "X" Then
  766.             MsgBox("Player X Won!")
  767.             scoreX.Text = Val(scoreX.Text) + 1
  768.  
  769.         End If
  770.         If Button3.Text = "X" And Button6.Text = "X" And Button9.Text = "X" Then
  771.             MsgBox("Player X Won!")
  772.             scoreX.Text = Val(scoreX.Text) + 1
  773.  
  774.         End If
  775.         If Button1.Text = "X" And Button5.Text = "X" And Button9.Text = "X" Then
  776.             MsgBox("Player X Won!")
  777.             scoreX.Text = Val(scoreX.Text) + 1
  778.  
  779.         End If
  780.         If Button3.Text = "X" And Button5.Text = "X" And Button7.Text = "X" Then
  781.             MsgBox("Player X Won!")
  782.             scoreX.Text = Val(scoreX.Text) + 1
  783.  
  784.         End If
  785.  
  786.  
  787.         'player O wins
  788.  
  789.         If Button1.Text = "O" And Button2.Text = "O" And Button3.Text = "O" Then
  790.             MsgBox("Player O Won!")
  791.             scoreO.Text = Val(scoreX.Text) + 1
  792.  
  793.         End If
  794.         If Button4.Text = "O" And Button5.Text = "O" And Button6.Text = "O" Then
  795.             MsgBox("Player O Won!")
  796.             scoreO.Text = Val(scoreX.Text) + 1
  797.  
  798.         End If
  799.         If Button7.Text = "O" And Button8.Text = "O" And Button9.Text = "O" Then
  800.             MsgBox("Player O Won!")
  801.             scoreO.Text = Val(scoreX.Text) + 1
  802.  
  803.         End If
  804.         If Button1.Text = "O" And Button4.Text = "O" And Button7.Text = "O" Then
  805.             MsgBox("Player O Won!")
  806.             scoreO.Text = Val(scoreX.Text) + 1
  807.  
  808.         End If
  809.         If Button2.Text = "O" And Button5.Text = "O" And Button8.Text = "O" Then
  810.             MsgBox("Player O Won!")
  811.             scoreO.Text = Val(scoreX.Text) + 1
  812.  
  813.         End If
  814.         If Button3.Text = "O" And Button6.Text = "O" And Button9.Text = "O" Then
  815.             MsgBox("Player O Won!")
  816.             scoreO.Text = Val(scoreX.Text) + 1
  817.  
  818.         End If
  819.         If Button1.Text = "O" And Button5.Text = "O" And Button9.Text = "O" Then
  820.             MsgBox("Player O Won!")
  821.             scoreO.Text = Val(scoreX.Text) + 1
  822.  
  823.         End If
  824.         If Button3.Text = "O" And Button5.Text = "O" And Button7.Text = "O" Then
  825.             MsgBox("Player O Won!")
  826.             scoreO.Text = Val(scoreX.Text) + 1
  827.  
  828.         End If
  829.      If Button1.Enabled = False And Button2.Enabled = False And Button3.Enabled = False And Button4.Enabled = False _
  830.    And Button5.Enabled = False And Button6.Enabled = False And Button7.Enabled = False And Button8.Enabled = False _
  831.    And Button9.Enabled = False Then MsgBox("Its draw!!!")
  832.  
  833.     End Sub
  834.  
  835.     Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
  836.         If turn.Text = "X" Then
  837.             Button9.Text = "X"
  838.             turn.Text = "O"
  839.         Else
  840.             Button9.Text = "O"
  841.             turn.Text = "X"
  842.         End If
  843.         Button9.Enabled = False
  844.  
  845.         'player X wins
  846.  
  847.         If Button1.Text = "X" And Button2.Text = "X" And Button3.Text = "X" Then
  848.             MsgBox("Player X Won!")
  849.             scoreX.Text = Val(scoreX.Text) + 1
  850.  
  851.         End If
  852.         If Button4.Text = "X" And Button5.Text = "X" And Button6.Text = "X" Then
  853.             MsgBox("Player X Won!")
  854.             scoreX.Text = Val(scoreX.Text) + 1
  855.  
  856.         End If
  857.         If Button7.Text = "X" And Button8.Text = "X" And Button9.Text = "X" Then
  858.             MsgBox("Player X Won!")
  859.             scoreX.Text = Val(scoreX.Text) + 1
  860.  
  861.         End If
  862.         If Button1.Text = "X" And Button4.Text = "X" And Button7.Text = "X" Then
  863.             MsgBox("Player X Won!")
  864.             scoreX.Text = Val(scoreX.Text) + 1
  865.  
  866.         End If
  867.         If Button2.Text = "X" And Button5.Text = "X" And Button8.Text = "X" Then
  868.             MsgBox("Player X Won!")
  869.             scoreX.Text = Val(scoreX.Text) + 1
  870.  
  871.         End If
  872.         If Button3.Text = "X" And Button6.Text = "X" And Button9.Text = "X" Then
  873.             MsgBox("Player X Won!")
  874.             scoreX.Text = Val(scoreX.Text) + 1
  875.  
  876.         End If
  877.         If Button1.Text = "X" And Button5.Text = "X" And Button9.Text = "X" Then
  878.             MsgBox("Player X Won!")
  879.             scoreX.Text = Val(scoreX.Text) + 1
  880.  
  881.         End If
  882.         If Button3.Text = "X" And Button5.Text = "X" And Button7.Text = "X" Then
  883.             MsgBox("Player X Won!")
  884.             scoreX.Text = Val(scoreX.Text) + 1
  885.  
  886.             'player O wins
  887.        End If
  888.         If Button4.Text = "O" And Button5.Text = "O" And Button6.Text = "O" Then
  889.             MsgBox("Player O Won!")
  890.             scoreO.Text = Val(scoreX.Text) + 1
  891.            
  892.  
  893.         End If
  894.         If Button1.Text = "O" And Button4.Text = "O" And Button7.Text = "O" Then
  895.             MsgBox("Player O Won!")
  896.             scoreO.Text = Val(scoreX.Text) + 1
  897.  
  898.         End If
  899.         If Button3.Text = "O" And Button6.Text = "O" And Button9.Text = "O" Then
  900.             MsgBox("Player O Won!")
  901.             scoreO.Text = Val(scoreX.Text) + 1
  902.  
  903.         End If
  904.         If Button3.Text = "O" And Button5.Text = "O" And Button7.Text = "O" Then
  905.             MsgBox("Player O Won!")
  906.             scoreO.Text = Val(scoreX.Text) + 1
  907.  
  908.         End If
  909.         If Button1.Enabled = False And Button2.Enabled = False And Button3.Enabled = False And Button4.Enabled = False _
  910.   And Button5.Enabled = False And Button6.Enabled = False And Button7.Enabled = False And Button8.Enabled = False _
  911.   And Button9.Enabled = False Then MsgBox("Its draw!!!")
  912.  
  913.     End Sub
  914.  
  915.  
  916.  
  917.     Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click
  918.         Button1.Text = " "
  919.         Button1.Enabled = True
  920.  
  921.  
  922.         Button2.Text = " "
  923.         Button2.Enabled = True
  924.  
  925.         Button3.Text = " "
  926.         Button3.Enabled = True
  927.  
  928.         Button4.Text = " "
  929.         Button4.Enabled = True
  930.  
  931.         Button5.Text = " "
  932.         Button5.Enabled = True
  933.  
  934.         Button6.Text = " "
  935.         Button6.Enabled = True
  936.  
  937.         Button7.Text = " "
  938.         Button7.Enabled = True
  939.  
  940.         Button8.Text = " "
  941.         Button8.Enabled = True
  942.  
  943.         Button9.Text = " "
  944.         Button9.Enabled = True
  945.         turn.Text = "X"
  946.     End Sub
  947.  
  948.  
  949.  
  950.  
  951.  
  952.     Private Sub Button11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button11.Click
  953.         Button1.Text = " "
  954.         Button1.Enabled = True
  955.  
  956.  
  957.         Button2.Text = " "
  958.         Button2.Enabled = True
  959.  
  960.         Button3.Text = " "
  961.         Button3.Enabled = True
  962.  
  963.         Button4.Text = " "
  964.         Button4.Enabled = True
  965.  
  966.         Button5.Text = " "
  967.         Button5.Enabled = True
  968.  
  969.         Button6.Text = " "
  970.         Button6.Enabled = True
  971.  
  972.         Button7.Text = " "
  973.         Button7.Enabled = True
  974.  
  975.         Button8.Text = " "
  976.         Button8.Enabled = True
  977.  
  978.         Button9.Text = " "
  979.         Button9.Enabled = True
  980.  
  981.         scoreO.Text = "0"
  982.         scoreX.Text = "0"
  983.  
  984.         turn.Text = "X"
  985.  
  986.     End Sub
  987.  
  988.  
  989.     Private Sub Label5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
  990.         Me.Hide()
  991.         Form1.Show()
  992.     End Sub
  993.  
  994.     Private Sub Button12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button12.Click
  995.         Me.Hide()
  996.         Form1.Show()
  997.     End Sub
  998.  
  999. End Class
Advertisement
RAW Paste Data Copied
Advertisement