Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Class Form1
- Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
- If Button2.Text = "X" Then
- If Button3.Text = "X" Then
- If Button4.Text = "X" Then
- If Button6.Text = "X" Then
- End If
- End If
- End If
- ElseIf Button3.Text = " " Then
- Button3.Text = "O"
- End If
- End Sub
- Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
- Dim a, b, c As String 'A = button 3, A=1,B=2,C=3, random number gen 1-3 then num = a,b or c then txtbox= the letter, changed button
- Dim rnd As Double
- Dim rn As New Random
- ListBox1.Items.Add(rnd)
- Button2.Enabled = False
- Button2.Text = "X"
- If Button3.Text = "X" Then
- ElseIf Button3.Text = " " Then
- a = 1
- If Button6.Text = " " Then
- b = 2
- If Button5.Text = " " Then
- c = 3
- End If
- End If
- rnd = (rn.Next(1, 4)) 'random # gen, from number 1-3
- End If
- If rnd = 1 Then
- Button3.Text = "O"
- Button3.Enabled = False
- End If
- If rnd = 2 Then
- Button6.Text = "O"
- Button6.Enabled = False
- End If
- If rnd = 3 Then
- Button5.Text = "O"
- Button5.Enabled = False
- End If
- ListBox1.Items.Add(rnd)
- If rnd = 1 Then 'Debugger
- ListBox1.Items.Add("Bot placed O on A2")
- ElseIf rnd = 2 Then
- ListBox1.Items.Add("Bot placed O on B2")
- ElseIf rnd = 3 Then
- ListBox1.Items.Add("Bot placed O on B1")
- End If
- End Sub
- Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
- Dim a, b, c As String 'A = button 3, A=1,B=2,C=3, random number gen 1-3 then num = a,b or c then txtbox= the letter, changed button
- Dim rnd As Double
- Dim rn As New Random
- If Button3.Text = "O" Then
- Button3.Enabled = False
- Button3.Text = "O"
- ElseIf Button3.Text = " " Then
- Button3.Enabled = False
- Button3.Text = "X"
- End If
- If Button3.Text = "X" Then
- Button2.Text = " "
- a = 1
- If Button6.Text = " " Then
- b = 2
- If Button4.Text = " " Then
- c = 3
- End If
- End If
- rnd = (rn.Next(1, 4)) 'random # gen, from number 1-3
- End If
- If rnd = 1 Then
- Button2.Text = "O"
- Button2.Enabled = False
- End If
- If rnd = 2 Then
- Button6.Text = "O"
- Button6.Enabled = False
- End If
- If rnd = 3 Then
- Button4.Text = "O"
- Button4.Enabled = False
- End If
- ListBox1.Items.Add(rnd)
- If rnd = 1 Then 'Debugger
- ListBox1.Items.Add("Bot placed O on A2")
- ElseIf rnd = 2 Then
- ListBox1.Items.Add("Bot placed O on B2")
- ElseIf rnd = 3 Then
- ListBox1.Items.Add("Bot placed O on A3")
- End If
- End Sub
- Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
- Dim a, b, c As String 'A = button 3, A=1,B=2,C=3, random number gen 1-3 then num = a,b or c then txtbox= the letter, changed button
- Dim rnd As Double
- Dim rn As New Random
- If Button4.Text = "O" Then
- Button4.Enabled = False
- Button4.Text = "O"
- ElseIf Button4.Text = " " Then
- Button4.Enabled = False
- Button4.Text = "X"
- End If
- If Button4.Text = "X" Then
- Button3.Text = " "
- a = 1
- If Button6.Text = " " Then
- b = 2
- If Button7.Text = " " Then
- c = 3
- End If
- End If
- rnd = (rn.Next(1, 4)) 'random # gen, from number 1-3
- End If
- If rnd = 1 Then
- Button4.Text = "O"
- Button4.Enabled = False
- End If
- If rnd = 2 Then
- Button6.Text = "O"
- Button6.Enabled = False
- End If
- If rnd = 3 Then
- Button7.Text = "O"
- Button7.Enabled = False
- End If
- ListBox1.Items.Add(rnd)
- If rnd = 1 Then 'Debugger
- ListBox1.Items.Add("Bot placed O on A2")
- ElseIf rnd = 2 Then
- ListBox1.Items.Add("Bot placed O on B2")
- ElseIf rnd = 3 Then
- ListBox1.Items.Add("Bot placed O on B3")
- End If
- End Sub
- Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
- Dim a, b, c As String 'A = button 3, A=1,B=2,C=3, random number gen 1-3 then num = a,b or c then txtbox= the letter, changed button
- Dim rnd As Double
- Dim rn As New Random
- If Button5.Text = "O" Then
- Button5.Enabled = False
- Button5.Text = "O"
- ElseIf Button5.Text = " " Then
- Button5.Enabled = False
- Button5.Text = "X"
- End If
- If Button5.Text = "X" Then
- Button2.Text = " "
- a = 1
- If Button6.Text = " " Then
- b = 2
- If Button8.Text = " " Then
- c = 3
- End If
- End If
- rnd = (rn.Next(1, 4)) 'random # gen, from number 1-3
- End If
- If rnd = 1 Then
- Button2.Text = "O"
- Button2.Enabled = False
- End If
- If rnd = 2 Then
- Button6.Text = "O"
- Button6.Enabled = False
- End If
- If rnd = 3 Then
- Button8.Text = "O"
- Button8.Enabled = False
- End If
- ListBox1.Items.Add(rnd)
- If rnd = 1 Then 'Debugger
- ListBox1.Items.Add("Bot placed O on A1")
- ElseIf rnd = 2 Then
- ListBox1.Items.Add("Bot placed O on B2")
- ElseIf rnd = 3 Then
- ListBox1.Items.Add("Bot placed O on C1")
- End If
- End Sub
- 'This code is a bit messed up
- Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
- Dim a, b, c, d As String 'A = button 3, A=1,B=2,C=3, random number gen 1-3 then num = a,b or c then txtbox= the letter, changed button
- Dim rnd As Double
- Dim rn As New Random
- If Button6.Text = "O" Then
- Button6.Enabled = False
- Button6.Text = "O"
- ElseIf Button6.Text = " " Then
- Button6.Enabled = False
- Button6.Text = "X"
- End If
- If Button5.Text = "X" Then
- Button2.Text = " "
- a = 1
- If Button6.Text = " " Then
- b = 2
- If Button8.Text = " " Then
- c = 3
- If Button9.Text = " " Then
- d = 4
- End If
- End If
- End If
- rnd = (rn.Next(1, 5)) 'Middle square, code changes a bit for four spaces
- End If
- If rnd = 1 Then
- Button3.Text = "O"
- Button3.Enabled = False
- End If
- If rnd = 2 Then
- Button7.Text = "O"
- Button7.Enabled = False
- End If
- If rnd = 3 Then
- Button9.Text = "O"
- Button9.Enabled = False
- End If
- If rnd = 4 Then
- Button5.Text = "O"
- Button5.Enabled = False
- End If
- ListBox1.Items.Add(rnd)
- If rnd = 1 Then 'Debugger
- ListBox1.Items.Add("Bot placed O on A2")
- ElseIf rnd = 2 Then
- ListBox1.Items.Add("Bot placed O on B3")
- ElseIf rnd = 3 Then
- ListBox1.Items.Add("Bot placed O on C2")
- ElseIf rnd = 4 Then
- ListBox1.Items.Add("Bot placed O on b1")
- End If
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement