Advertisement
rohits134

Tic-Tac-Toe

Jun 15th, 2012
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 24.49 KB | None | 0 0
  1. Public Class Form1
  2.  
  3.     Dim value1 As Integer
  4.     Dim value2 As Integer
  5.  
  6.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  7.         Button1.Enabled = False
  8.         value1 = value1 + 1
  9.         If value1 = 1 Or value1 = 3 Or value1 = 5 Or value1 = 7 Or value1 = 9 Then
  10.             Button1.BackColor = Color.DarkGreen
  11.             Button1.Text = "X"
  12.         Else
  13.             Button1.BackColor = Color.IndianRed
  14.             Button1.Text = "O"
  15.         End If
  16.         If Button1.Text = "X" And Button5.Text = "X" And Button9.Text = "X" Then
  17.             TextBox1.Text = "Player 1 wins"
  18.  
  19.         ElseIf Button1.Text = "X" And Button2.Text = "X" And Button3.Text = "X" Then
  20.             TextBox1.Text = "Player 1 wins"
  21.  
  22.         ElseIf Button1.Text = "X" And Button4.Text = "X" And Button7.Text = "X" Then
  23.             TextBox1.Text = "Player 1 wins"
  24.  
  25.         ElseIf Button2.Text = "X" And Button5.Text = "X" And Button8.Text = "X" Then
  26.             TextBox1.Text = "Player 1 wins"
  27.  
  28.         ElseIf Button3.Text = "X" And Button6.Text = "X" And Button9.Text = "X" Then
  29.             TextBox1.Text = "Player 1 wins"
  30.  
  31.         ElseIf Button4.Text = "X" And Button5.Text = "X" And Button6.Text = "X" Then
  32.             TextBox1.Text = "Player 1 wins"
  33.  
  34.         ElseIf Button7.Text = "X" And Button8.Text = "X" And Button9.Text = "X" Then
  35.             TextBox1.Text = "Player 1 wins"
  36.  
  37.         ElseIf Button3.Text = "X" And Button5.Text = "X" And Button7.Text = "X" Then
  38.             TextBox1.Text = "Player 1 wins"
  39.  
  40.         ElseIf value1 = 9 Then
  41.             TextBox1.Text = "DRAW"
  42.  
  43.         End If
  44.  
  45.         If Button1.Text = "O" And Button5.Text = "O" And Button9.Text = "Ö" Then
  46.             TextBox1.Text = "Player 2 wins"
  47.  
  48.         ElseIf Button1.Text = "O" And Button2.Text = "O" And Button3.Text = "O" Then
  49.             TextBox1.Text = "Player 2 wins"
  50.  
  51.         ElseIf Button1.Text = "O" And Button4.Text = "O" And Button7.Text = "O" Then
  52.             TextBox1.Text = "Player 2 wins"
  53.  
  54.         ElseIf Button2.Text = "O" And Button5.Text = "O" And Button8.Text = "O" Then
  55.             TextBox1.Text = "Player 2 wins"
  56.  
  57.         ElseIf Button3.Text = "O" And Button6.Text = "O" And Button9.Text = "O" Then
  58.             TextBox1.Text = "Player 2 wins"
  59.  
  60.         ElseIf Button4.Text = "O" And Button5.Text = "O" And Button6.Text = "O" Then
  61.             TextBox1.Text = "Player 2 wins"
  62.  
  63.         ElseIf Button7.Text = "O" And Button8.Text = "O" And Button9.Text = "O" Then
  64.             TextBox1.Text = "Player 2 wins"
  65.  
  66.         ElseIf Button3.Text = "O" And Button5.Text = "O" And Button7.Text = "O" Then
  67.             TextBox1.Text = "Player 2 wins"
  68.  
  69.         ElseIf value1 = 9 Then
  70.             TextBox1.Text = "DRAW"
  71.  
  72.         End If
  73.     End Sub
  74.  
  75.     Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
  76.         Button2.Enabled = False
  77.         value1 = value1 + 1
  78.         If value1 = 1 Or value1 = 3 Or value1 = 5 Or value1 = 7 Or value1 = 9 Then
  79.             Button2.BackColor = Color.DarkGreen
  80.             Button2.Text = "X"
  81.         Else
  82.             Button2.BackColor = Color.IndianRed
  83.             Button2.Text = "O"
  84.         End If
  85.         If Button1.Text = "X" And Button5.Text = "X" And Button9.Text = "X" Then
  86.             TextBox1.Text = "Player 1 wins"
  87.  
  88.         ElseIf Button1.Text = "X" And Button2.Text = "X" And Button3.Text = "X" Then
  89.             TextBox1.Text = "Player 1 wins"
  90.  
  91.         ElseIf Button1.Text = "X" And Button4.Text = "X" And Button7.Text = "X" Then
  92.             TextBox1.Text = "Player 1 wins"
  93.  
  94.         ElseIf Button2.Text = "X" And Button5.Text = "X" And Button8.Text = "X" Then
  95.             TextBox1.Text = "Player 1 wins"
  96.  
  97.         ElseIf Button3.Text = "X" And Button6.Text = "X" And Button9.Text = "X" Then
  98.             TextBox1.Text = "Player 1 wins"
  99.  
  100.         ElseIf Button4.Text = "X" And Button5.Text = "X" And Button6.Text = "X" Then
  101.             TextBox1.Text = "Player 1 wins"
  102.  
  103.         ElseIf Button7.Text = "X" And Button8.Text = "X" And Button9.Text = "X" Then
  104.             TextBox1.Text = "Player 1 wins"
  105.  
  106.         ElseIf Button3.Text = "X" And Button5.Text = "X" And Button7.Text = "X" Then
  107.             TextBox1.Text = "Player 1 wins"
  108.  
  109.         ElseIf value1 = 9 Then
  110.             TextBox1.Text = "DRAW"
  111.  
  112.         End If
  113.  
  114.         If Button1.Text = "O" And Button5.Text = "O" And Button9.Text = "Ö" Then
  115.             TextBox1.Text = "Player 2 wins"
  116.  
  117.         ElseIf Button1.Text = "O" And Button2.Text = "O" And Button3.Text = "O" Then
  118.             TextBox1.Text = "Player 2 wins"
  119.  
  120.         ElseIf Button1.Text = "O" And Button4.Text = "O" And Button7.Text = "O" Then
  121.             TextBox1.Text = "Player 2 wins"
  122.  
  123.         ElseIf Button2.Text = "O" And Button5.Text = "O" And Button8.Text = "O" Then
  124.             TextBox1.Text = "Player 2 wins"
  125.  
  126.         ElseIf Button3.Text = "O" And Button6.Text = "O" And Button9.Text = "O" Then
  127.             TextBox1.Text = "Player 2 wins"
  128.  
  129.         ElseIf Button4.Text = "O" And Button5.Text = "O" And Button6.Text = "O" Then
  130.             TextBox1.Text = "Player 2 wins"
  131.  
  132.         ElseIf Button7.Text = "O" And Button8.Text = "O" And Button9.Text = "O" Then
  133.             TextBox1.Text = "Player 2 wins"
  134.  
  135.         ElseIf Button3.Text = "O" And Button5.Text = "O" And Button7.Text = "O" Then
  136.             TextBox1.Text = "Player 2 wins"
  137.  
  138.         ElseIf value1 = 9 Then
  139.             TextBox1.Text = "DRAW"
  140.  
  141.         End If
  142.     End Sub
  143.  
  144.     Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
  145.         Button3.Enabled = False
  146.         value1 = value1 + 1
  147.         If value1 = 1 Or value1 = 3 Or value1 = 5 Or value1 = 7 Or value1 = 9 Then
  148.             Button3.BackColor = Color.DarkGreen
  149.             Button3.Text = "X"
  150.         Else
  151.             Button3.BackColor = Color.IndianRed
  152.             Button3.Text = "O"
  153.         End If
  154.         If Button1.Text = "X" And Button5.Text = "X" And Button9.Text = "X" Then
  155.             TextBox1.Text = "Player 1 wins"
  156.  
  157.         ElseIf Button1.Text = "X" And Button2.Text = "X" And Button3.Text = "X" Then
  158.             TextBox1.Text = "Player 1 wins"
  159.  
  160.         ElseIf Button1.Text = "X" And Button4.Text = "X" And Button7.Text = "X" Then
  161.             TextBox1.Text = "Player 1 wins"
  162.  
  163.         ElseIf Button2.Text = "X" And Button5.Text = "X" And Button8.Text = "X" Then
  164.             TextBox1.Text = "Player 1 wins"
  165.  
  166.         ElseIf Button3.Text = "X" And Button6.Text = "X" And Button9.Text = "X" Then
  167.             TextBox1.Text = "Player 1 wins"
  168.  
  169.         ElseIf Button4.Text = "X" And Button5.Text = "X" And Button6.Text = "X" Then
  170.             TextBox1.Text = "Player 1 wins"
  171.  
  172.         ElseIf Button7.Text = "X" And Button8.Text = "X" And Button9.Text = "X" Then
  173.             TextBox1.Text = "Player 1 wins"
  174.  
  175.         ElseIf Button3.Text = "X" And Button5.Text = "X" And Button7.Text = "X" Then
  176.             TextBox1.Text = "Player 1 wins"
  177.  
  178.         ElseIf value1 = 9 Then
  179.             TextBox1.Text = "DRAW"
  180.  
  181.         End If
  182.  
  183.         If Button1.Text = "O" And Button5.Text = "O" And Button9.Text = "Ö" Then
  184.             TextBox1.Text = "Player 2 wins"
  185.  
  186.         ElseIf Button1.Text = "O" And Button2.Text = "O" And Button3.Text = "O" Then
  187.             TextBox1.Text = "Player 2 wins"
  188.  
  189.         ElseIf Button1.Text = "O" And Button4.Text = "O" And Button7.Text = "O" Then
  190.             TextBox1.Text = "Player 2 wins"
  191.  
  192.         ElseIf Button2.Text = "O" And Button5.Text = "O" And Button8.Text = "O" Then
  193.             TextBox1.Text = "Player 2 wins"
  194.  
  195.         ElseIf Button3.Text = "O" And Button6.Text = "O" And Button9.Text = "O" Then
  196.             TextBox1.Text = "Player 2 wins"
  197.  
  198.         ElseIf Button4.Text = "O" And Button5.Text = "O" And Button6.Text = "O" Then
  199.             TextBox1.Text = "Player 2 wins"
  200.  
  201.         ElseIf Button7.Text = "O" And Button8.Text = "O" And Button9.Text = "O" Then
  202.             TextBox1.Text = "Player 2 wins"
  203.  
  204.         ElseIf Button3.Text = "O" And Button5.Text = "O" And Button7.Text = "O" Then
  205.             TextBox1.Text = "Player 2 wins"
  206.  
  207.         ElseIf value1 = 9 Then
  208.             TextBox1.Text = "DRAW"
  209.  
  210.         End If
  211.     End Sub
  212.  
  213.     Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
  214.         Button4.Enabled = False
  215.         value1 = value1 + 1
  216.         If value1 = 1 Or value1 = 3 Or value1 = 5 Or value1 = 7 Or value1 = 9 Then
  217.             Button4.BackColor = Color.DarkGreen
  218.             Button4.Text = "X"
  219.         Else
  220.             Button4.BackColor = Color.IndianRed
  221.             Button4.Text = "O"
  222.         End If
  223.         If Button1.Text = "X" And Button5.Text = "X" And Button9.Text = "X" Then
  224.             TextBox1.Text = "Player 1 wins"
  225.  
  226.         ElseIf Button1.Text = "X" And Button2.Text = "X" And Button3.Text = "X" Then
  227.             TextBox1.Text = "Player 1 wins"
  228.  
  229.         ElseIf Button1.Text = "X" And Button4.Text = "X" And Button7.Text = "X" Then
  230.             TextBox1.Text = "Player 1 wins"
  231.  
  232.         ElseIf Button2.Text = "X" And Button5.Text = "X" And Button8.Text = "X" Then
  233.             TextBox1.Text = "Player 1 wins"
  234.  
  235.         ElseIf Button3.Text = "X" And Button6.Text = "X" And Button9.Text = "X" Then
  236.             TextBox1.Text = "Player 1 wins"
  237.  
  238.         ElseIf Button4.Text = "X" And Button5.Text = "X" And Button6.Text = "X" Then
  239.             TextBox1.Text = "Player 1 wins"
  240.  
  241.         ElseIf Button7.Text = "X" And Button8.Text = "X" And Button9.Text = "X" Then
  242.             TextBox1.Text = "Player 1 wins"
  243.  
  244.         ElseIf Button3.Text = "X" And Button5.Text = "X" And Button7.Text = "X" Then
  245.             TextBox1.Text = "Player 1 wins"
  246.  
  247.         ElseIf value1 = 9 Then
  248.             TextBox1.Text = "DRAW"
  249.  
  250.         End If
  251.  
  252.         If Button1.Text = "O" And Button5.Text = "O" And Button9.Text = "Ö" Then
  253.             TextBox1.Text = "Player 2 wins"
  254.  
  255.         ElseIf Button1.Text = "O" And Button2.Text = "O" And Button3.Text = "O" Then
  256.             TextBox1.Text = "Player 2 wins"
  257.  
  258.         ElseIf Button1.Text = "O" And Button4.Text = "O" And Button7.Text = "O" Then
  259.             TextBox1.Text = "Player 2 wins"
  260.  
  261.         ElseIf Button2.Text = "O" And Button5.Text = "O" And Button8.Text = "O" Then
  262.             TextBox1.Text = "Player 2 wins"
  263.  
  264.         ElseIf Button3.Text = "O" And Button6.Text = "O" And Button9.Text = "O" Then
  265.             TextBox1.Text = "Player 2 wins"
  266.  
  267.         ElseIf Button4.Text = "O" And Button5.Text = "O" And Button6.Text = "O" Then
  268.             TextBox1.Text = "Player 2 wins"
  269.  
  270.         ElseIf Button7.Text = "O" And Button8.Text = "O" And Button9.Text = "O" Then
  271.             TextBox1.Text = "Player 2 wins"
  272.  
  273.         ElseIf Button3.Text = "O" And Button5.Text = "O" And Button7.Text = "O" Then
  274.             TextBox1.Text = "Player 2 wins"
  275.  
  276.         ElseIf value1 = 9 Then
  277.             TextBox1.Text = "DRAW"
  278.  
  279.         End If
  280.     End Sub
  281.  
  282.     Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
  283.         Button5.Enabled = False
  284.         value1 = value1 + 1
  285.         If value1 = 1 Or value1 = 3 Or value1 = 5 Or value1 = 7 Or value1 = 9 Then
  286.             Button5.BackColor = Color.DarkGreen
  287.             Button5.Text = "X"
  288.         Else
  289.             Button5.BackColor = Color.IndianRed
  290.             Button5.Text = "O"
  291.         End If
  292.         If Button1.Text = "X" And Button5.Text = "X" And Button9.Text = "X" Then
  293.             TextBox1.Text = "Player 1 wins"
  294.  
  295.         ElseIf Button1.Text = "X" And Button2.Text = "X" And Button3.Text = "X" Then
  296.             TextBox1.Text = "Player 1 wins"
  297.  
  298.         ElseIf Button1.Text = "X" And Button4.Text = "X" And Button7.Text = "X" Then
  299.             TextBox1.Text = "Player 1 wins"
  300.  
  301.         ElseIf Button2.Text = "X" And Button5.Text = "X" And Button8.Text = "X" Then
  302.             TextBox1.Text = "Player 1 wins"
  303.  
  304.         ElseIf Button3.Text = "X" And Button6.Text = "X" And Button9.Text = "X" Then
  305.             TextBox1.Text = "Player 1 wins"
  306.  
  307.         ElseIf Button4.Text = "X" And Button5.Text = "X" And Button6.Text = "X" Then
  308.             TextBox1.Text = "Player 1 wins"
  309.  
  310.         ElseIf Button7.Text = "X" And Button8.Text = "X" And Button9.Text = "X" Then
  311.             TextBox1.Text = "Player 1 wins"
  312.  
  313.         ElseIf Button3.Text = "X" And Button5.Text = "X" And Button7.Text = "X" Then
  314.             TextBox1.Text = "Player 1 wins"
  315.  
  316.         ElseIf value1 = 9 Then
  317.             TextBox1.Text = "DRAW"
  318.  
  319.         End If
  320.  
  321.         If Button1.Text = "O" And Button5.Text = "O" And Button9.Text = "Ö" Then
  322.             TextBox1.Text = "Player 2 wins"
  323.  
  324.         ElseIf Button1.Text = "O" And Button2.Text = "O" And Button3.Text = "O" Then
  325.             TextBox1.Text = "Player 2 wins"
  326.  
  327.         ElseIf Button1.Text = "O" And Button4.Text = "O" And Button7.Text = "O" Then
  328.             TextBox1.Text = "Player 2 wins"
  329.  
  330.         ElseIf Button2.Text = "O" And Button5.Text = "O" And Button8.Text = "O" Then
  331.             TextBox1.Text = "Player 2 wins"
  332.  
  333.         ElseIf Button3.Text = "O" And Button6.Text = "O" And Button9.Text = "O" Then
  334.             TextBox1.Text = "Player 2 wins"
  335.  
  336.         ElseIf Button4.Text = "O" And Button5.Text = "O" And Button6.Text = "O" Then
  337.             TextBox1.Text = "Player 2 wins"
  338.  
  339.         ElseIf Button7.Text = "O" And Button8.Text = "O" And Button9.Text = "O" Then
  340.             TextBox1.Text = "Player 2 wins"
  341.  
  342.         ElseIf Button3.Text = "O" And Button5.Text = "O" And Button7.Text = "O" Then
  343.             TextBox1.Text = "Player 2 wins"
  344.  
  345.         ElseIf value1 = 9 Then
  346.             TextBox1.Text = "DRAW"
  347.  
  348.         End If
  349.     End Sub
  350.  
  351.     Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
  352.         Button6.Enabled = False
  353.         value1 = value1 + 1
  354.         If value1 = 1 Or value1 = 3 Or value1 = 5 Or value1 = 7 Or value1 = 9 Then
  355.             Button6.BackColor = Color.DarkGreen
  356.             Button6.Text = "X"
  357.         Else
  358.             Button6.BackColor = Color.IndianRed
  359.             Button6.Text = "O"
  360.         End If
  361.         If Button1.Text = "X" And Button5.Text = "X" And Button9.Text = "X" Then
  362.             TextBox1.Text = "Player 1 wins"
  363.  
  364.         ElseIf Button1.Text = "X" And Button2.Text = "X" And Button3.Text = "X" Then
  365.             TextBox1.Text = "Player 1 wins"
  366.  
  367.         ElseIf Button1.Text = "X" And Button4.Text = "X" And Button7.Text = "X" Then
  368.             TextBox1.Text = "Player 1 wins"
  369.  
  370.         ElseIf Button2.Text = "X" And Button5.Text = "X" And Button8.Text = "X" Then
  371.             TextBox1.Text = "Player 1 wins"
  372.  
  373.         ElseIf Button3.Text = "X" And Button6.Text = "X" And Button9.Text = "X" Then
  374.             TextBox1.Text = "Player 1 wins"
  375.  
  376.         ElseIf Button4.Text = "X" And Button5.Text = "X" And Button6.Text = "X" Then
  377.             TextBox1.Text = "Player 1 wins"
  378.  
  379.         ElseIf Button7.Text = "X" And Button8.Text = "X" And Button9.Text = "X" Then
  380.             TextBox1.Text = "Player 1 wins"
  381.  
  382.         ElseIf Button3.Text = "X" And Button5.Text = "X" And Button7.Text = "X" Then
  383.             TextBox1.Text = "Player 1 wins"
  384.  
  385.         ElseIf value1 = 9 Then
  386.             TextBox1.Text = "DRAW"
  387.  
  388.         End If
  389.  
  390.         If Button1.Text = "O" And Button5.Text = "O" And Button9.Text = "Ö" Then
  391.             TextBox1.Text = "Player 2 wins"
  392.  
  393.         ElseIf Button1.Text = "O" And Button2.Text = "O" And Button3.Text = "O" Then
  394.             TextBox1.Text = "Player 2 wins"
  395.  
  396.         ElseIf Button1.Text = "O" And Button4.Text = "O" And Button7.Text = "O" Then
  397.             TextBox1.Text = "Player 2 wins"
  398.  
  399.         ElseIf Button2.Text = "O" And Button5.Text = "O" And Button8.Text = "O" Then
  400.             TextBox1.Text = "Player 2 wins"
  401.  
  402.         ElseIf Button3.Text = "O" And Button6.Text = "O" And Button9.Text = "O" Then
  403.             TextBox1.Text = "Player 2 wins"
  404.  
  405.         ElseIf Button4.Text = "O" And Button5.Text = "O" And Button6.Text = "O" Then
  406.             TextBox1.Text = "Player 2 wins"
  407.  
  408.         ElseIf Button7.Text = "O" And Button8.Text = "O" And Button9.Text = "O" Then
  409.             TextBox1.Text = "Player 2 wins"
  410.  
  411.         ElseIf Button3.Text = "O" And Button5.Text = "O" And Button7.Text = "O" Then
  412.             TextBox1.Text = "Player 2 wins"
  413.  
  414.         ElseIf value1 = 9 Then
  415.             TextBox1.Text = "DRAW"
  416.  
  417.         End If
  418.     End Sub
  419.  
  420.     Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
  421.         Button7.Enabled = False
  422.         value1 = value1 + 1
  423.         If value1 = 1 Or value1 = 3 Or value1 = 5 Or value1 = 7 Or value1 = 9 Then
  424.             Button7.BackColor = Color.DarkGreen
  425.             Button7.Text = "X"
  426.         Else
  427.             Button7.BackColor = Color.IndianRed
  428.             Button7.Text = "O"
  429.         End If
  430.         If Button1.Text = "X" And Button5.Text = "X" And Button9.Text = "X" Then
  431.             TextBox1.Text = "Player 1 wins"
  432.  
  433.         ElseIf Button1.Text = "X" And Button2.Text = "X" And Button3.Text = "X" Then
  434.             TextBox1.Text = "Player 1 wins"
  435.  
  436.         ElseIf Button1.Text = "X" And Button4.Text = "X" And Button7.Text = "X" Then
  437.             TextBox1.Text = "Player 1 wins"
  438.  
  439.         ElseIf Button2.Text = "X" And Button5.Text = "X" And Button8.Text = "X" Then
  440.             TextBox1.Text = "Player 1 wins"
  441.  
  442.         ElseIf Button3.Text = "X" And Button6.Text = "X" And Button9.Text = "X" Then
  443.             TextBox1.Text = "Player 1 wins"
  444.  
  445.         ElseIf Button4.Text = "X" And Button5.Text = "X" And Button6.Text = "X" Then
  446.             TextBox1.Text = "Player 1 wins"
  447.  
  448.         ElseIf Button7.Text = "X" And Button8.Text = "X" And Button9.Text = "X" Then
  449.             TextBox1.Text = "Player 1 wins"
  450.  
  451.         ElseIf Button3.Text = "X" And Button5.Text = "X" And Button7.Text = "X" Then
  452.             TextBox1.Text = "Player 1 wins"
  453.  
  454.         ElseIf value1 = 9 Then
  455.             TextBox1.Text = "DRAW"
  456.  
  457.         End If
  458.  
  459.         If Button1.Text = "O" And Button5.Text = "O" And Button9.Text = "Ö" Then
  460.             TextBox1.Text = "Player 2 wins"
  461.  
  462.         ElseIf Button1.Text = "O" And Button2.Text = "O" And Button3.Text = "O" Then
  463.             TextBox1.Text = "Player 2 wins"
  464.  
  465.         ElseIf Button1.Text = "O" And Button4.Text = "O" And Button7.Text = "O" Then
  466.             TextBox1.Text = "Player 2 wins"
  467.  
  468.         ElseIf Button2.Text = "O" And Button5.Text = "O" And Button8.Text = "O" Then
  469.             TextBox1.Text = "Player 2 wins"
  470.  
  471.         ElseIf Button3.Text = "O" And Button6.Text = "O" And Button9.Text = "O" Then
  472.             TextBox1.Text = "Player 2 wins"
  473.  
  474.         ElseIf Button4.Text = "O" And Button5.Text = "O" And Button6.Text = "O" Then
  475.             TextBox1.Text = "Player 2 wins"
  476.  
  477.         ElseIf Button7.Text = "O" And Button8.Text = "O" And Button9.Text = "O" Then
  478.             TextBox1.Text = "Player 2 wins"
  479.  
  480.         ElseIf Button3.Text = "O" And Button5.Text = "O" And Button7.Text = "O" Then
  481.             TextBox1.Text = "Player 2 wins"
  482.  
  483.         ElseIf value1 = 9 Then
  484.             TextBox1.Text = "DRAW"
  485.  
  486.         End If
  487.     End Sub
  488.  
  489.     Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
  490.         Button8.Enabled = False
  491.         value1 = value1 + 1
  492.         If value1 = 1 Or value1 = 3 Or value1 = 5 Or value1 = 7 Or value1 = 9 Then
  493.             Button8.BackColor = Color.DarkGreen
  494.             Button8.Text = "X"
  495.         Else
  496.             Button8.BackColor = Color.IndianRed
  497.             Button8.Text = "O"
  498.         End If
  499.         If Button1.Text = "X" And Button5.Text = "X" And Button9.Text = "X" Then
  500.             TextBox1.Text = "Player 1 wins"
  501.  
  502.         ElseIf Button1.Text = "X" And Button2.Text = "X" And Button3.Text = "X" Then
  503.             TextBox1.Text = "Player 1 wins"
  504.  
  505.         ElseIf Button1.Text = "X" And Button4.Text = "X" And Button7.Text = "X" Then
  506.             TextBox1.Text = "Player 1 wins"
  507.  
  508.         ElseIf Button2.Text = "X" And Button5.Text = "X" And Button8.Text = "X" Then
  509.             TextBox1.Text = "Player 1 wins"
  510.  
  511.         ElseIf Button3.Text = "X" And Button6.Text = "X" And Button9.Text = "X" Then
  512.             TextBox1.Text = "Player 1 wins"
  513.  
  514.         ElseIf Button4.Text = "X" And Button5.Text = "X" And Button6.Text = "X" Then
  515.             TextBox1.Text = "Player 1 wins"
  516.  
  517.         ElseIf Button7.Text = "X" And Button8.Text = "X" And Button9.Text = "X" Then
  518.             TextBox1.Text = "Player 1 wins"
  519.  
  520.         ElseIf Button3.Text = "X" And Button5.Text = "X" And Button7.Text = "X" Then
  521.             TextBox1.Text = "Player 1 wins"
  522.  
  523.         ElseIf value1 = 9 Then
  524.             TextBox1.Text = "DRAW"
  525.  
  526.         End If
  527.  
  528.         If Button1.Text = "O" And Button5.Text = "O" And Button9.Text = "Ö" Then
  529.             TextBox1.Text = "Player 2 wins"
  530.  
  531.         ElseIf Button1.Text = "O" And Button2.Text = "O" And Button3.Text = "O" Then
  532.             TextBox1.Text = "Player 2 wins"
  533.  
  534.         ElseIf Button1.Text = "O" And Button4.Text = "O" And Button7.Text = "O" Then
  535.             TextBox1.Text = "Player 2 wins"
  536.  
  537.         ElseIf Button2.Text = "O" And Button5.Text = "O" And Button8.Text = "O" Then
  538.             TextBox1.Text = "Player 2 wins"
  539.  
  540.         ElseIf Button3.Text = "O" And Button6.Text = "O" And Button9.Text = "O" Then
  541.             TextBox1.Text = "Player 2 wins"
  542.  
  543.         ElseIf Button4.Text = "O" And Button5.Text = "O" And Button6.Text = "O" Then
  544.             TextBox1.Text = "Player 2 wins"
  545.  
  546.         ElseIf Button7.Text = "O" And Button8.Text = "O" And Button9.Text = "O" Then
  547.             TextBox1.Text = "Player 2 wins"
  548.  
  549.         ElseIf Button3.Text = "O" And Button5.Text = "O" And Button7.Text = "O" Then
  550.             TextBox1.Text = "Player 2 wins"
  551.  
  552.         ElseIf value1 = 9 Then
  553.             TextBox1.Text = "DRAW"
  554.  
  555.         End If
  556.     End Sub
  557.  
  558.     Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
  559.         Button9.Enabled = False
  560.         value1 = value1 + 1
  561.         If value1 = 1 Or value1 = 3 Or value1 = 5 Or value1 = 7 Or value1 = 9 Then
  562.             Button9.BackColor = Color.DarkGreen
  563.             Button9.Text = "X"
  564.         Else
  565.             Button9.BackColor = Color.IndianRed
  566.             Button9.Text = "O"
  567.         End If
  568.         If Button1.Text = "X" And Button5.Text = "X" And Button9.Text = "X" Then
  569.             TextBox1.Text = "Player 1 wins"
  570.  
  571.         ElseIf Button1.Text = "X" And Button2.Text = "X" And Button3.Text = "X" Then
  572.             TextBox1.Text = "Player 1 wins"
  573.  
  574.         ElseIf Button1.Text = "X" And Button4.Text = "X" And Button7.Text = "X" Then
  575.             TextBox1.Text = "Player 1 wins"
  576.  
  577.         ElseIf Button2.Text = "X" And Button5.Text = "X" And Button8.Text = "X" Then
  578.             TextBox1.Text = "Player 1 wins"
  579.  
  580.         ElseIf Button3.Text = "X" And Button6.Text = "X" And Button9.Text = "X" Then
  581.             TextBox1.Text = "Player 1 wins"
  582.  
  583.         ElseIf Button4.Text = "X" And Button5.Text = "X" And Button6.Text = "X" Then
  584.             TextBox1.Text = "Player 1 wins"
  585.  
  586.         ElseIf Button7.Text = "X" And Button8.Text = "X" And Button9.Text = "X" Then
  587.             TextBox1.Text = "Player 1 wins"
  588.  
  589.         ElseIf Button3.Text = "X" And Button5.Text = "X" And Button7.Text = "X" Then
  590.             TextBox1.Text = "Player 1 wins"
  591.  
  592.         ElseIf value1 = 9 Then
  593.             TextBox1.Text = "DRAW"
  594.  
  595.         End If
  596.  
  597.         If Button1.Text = "O" And Button5.Text = "O" And Button9.Text = "Ö" Then
  598.             TextBox1.Text = "Player 2 wins"
  599.  
  600.         ElseIf Button1.Text = "O" And Button2.Text = "O" And Button3.Text = "O" Then
  601.             TextBox1.Text = "Player 2 wins"
  602.  
  603.         ElseIf Button1.Text = "O" And Button4.Text = "O" And Button7.Text = "O" Then
  604.             TextBox1.Text = "Player 2 wins"
  605.  
  606.         ElseIf Button2.Text = "O" And Button5.Text = "O" And Button8.Text = "O" Then
  607.             TextBox1.Text = "Player 2 wins"
  608.  
  609.         ElseIf Button3.Text = "O" And Button6.Text = "O" And Button9.Text = "O" Then
  610.             TextBox1.Text = "Player 2 wins"
  611.  
  612.         ElseIf Button4.Text = "O" And Button5.Text = "O" And Button6.Text = "O" Then
  613.             TextBox1.Text = "Player 2 wins"
  614.  
  615.         ElseIf Button7.Text = "O" And Button8.Text = "O" And Button9.Text = "O" Then
  616.             TextBox1.Text = "Player 2 wins"
  617.  
  618.         ElseIf Button3.Text = "O" And Button5.Text = "O" And Button7.Text = "O" Then
  619.             TextBox1.Text = "Player 2 wins"
  620.  
  621.         ElseIf value1 = 9 Then
  622.             TextBox1.Text = "DRAW"
  623.  
  624.         End If
  625.     End Sub
  626.  
  627.     Private Sub btnQuit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnQuit.Click
  628.         End
  629.     End Sub
  630.  
  631. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement