Log in

View Full Version : [ask]=visual basic tic-tac-toe game= coding untuk draw/seri/tie


Permenkaret
20th November 2011, 02:13 AM
agan2....ada yang tau gak...coding untuk tic-tac-toe kalau permainan gak ada yang menang, alias draw/tie/seri

code yang udah gw bikin untuk menang gini:


Spoiler for code:






Private Sub win()

If Button1.Text = "X" And Button2.Text = "X" And Button3.Text = "X" Then

MsgBox("Player X wins!", MsgBoxStyle.Information)

Label3.Text += 1

Button1.Text = ""

Button2.Text = ""

Button3.Text = ""

Button4.Text = ""

Button5.Text = ""

Button6.Text = ""

Button7.Text = ""

Button8.Text = ""

Button9.Text = ""

End If



If Button1.Text = "X" And Button4.Text = "X" And Button7.Text = "X" Then

MsgBox("Player X wins!", MsgBoxStyle.Information)

Label3.Text += 1

Button1.Text = ""

Button2.Text = ""

Button3.Text = ""

Button4.Text = ""

Button5.Text = ""

Button6.Text = ""

Button7.Text = ""

Button8.Text = ""

Button9.Text = ""

End If



If Button1.Text = "X" And Button5.Text = "X" And Button9.Text = "X" Then

MsgBox("Player X wins!", MsgBoxStyle.Information)

Label3.Text += 1

Button1.Text = ""

Button2.Text = ""

Button3.Text = ""

Button4.Text = ""

Button5.Text = ""

Button6.Text = ""

Button7.Text = ""

Button8.Text = ""

Button9.Text = ""

End If



If Button2.Text = "X" And Button5.Text = "X" And Button8.Text = "X" Then

MsgBox("Player X wins!", MsgBoxStyle.Information)

Label3.Text += 1

Button1.Text = ""

Button2.Text = ""

Button3.Text = ""

Button4.Text = ""

Button5.Text = ""

Button6.Text = ""

Button7.Text = ""

Button8.Text = ""

Button9.Text = ""

End If



If Button3.Text = "X" And Button6.Text = "X" And Button9.Text = "X" Then

MsgBox("Player X wins!", MsgBoxStyle.Information)

Label3.Text += 1

Button1.Text = ""

Button2.Text = ""

Button3.Text = ""

Button4.Text = ""

Button5.Text = ""

Button6.Text = ""

Button7.Text = ""

Button8.Text = ""

Button9.Text = ""

End If



If Button3.Text = "X" And Button5.Text = "X" And Button7.Text = "X" Then

MsgBox("Player X wins!", MsgBoxStyle.Information)

Label3.Text += 1

Button1.Text = ""

Button2.Text = ""

Button3.Text = ""

Button4.Text = ""

Button5.Text = ""

Button6.Text = ""

Button7.Text = ""

Button8.Text = ""

Button9.Text = ""

End If



If Button4.Text = "X" And Button5.Text = "X" And Button6.Text = "X" Then

MsgBox("Player X wins!", MsgBoxStyle.Information)

Label3.Text += 1

Button1.Text = ""

Button2.Text = ""

Button3.Text = ""

Button4.Text = ""

Button5.Text = ""

Button6.Text = ""

Button7.Text = ""

Button8.Text = ""

Button9.Text = ""

End If



If Button7.Text = "X" And Button8.Text = "X" And Button9.Text = "X" Then

MsgBox("Player X wins!", MsgBoxStyle.Information)

Label3.Text += 1

Button1.Text = ""

Button2.Text = ""

Button3.Text = ""

Button4.Text = ""

Button5.Text = ""

Button6.Text = ""

Button7.Text = ""

Button8.Text = ""

Button9.Text = ""

End If



If Button1.Text = "O" And Button2.Text = "O" And Button3.Text = "O" Then

MsgBox("Player O wins!", MsgBoxStyle.Information)

Label4.Text += 1

Button1.Text = ""

Button2.Text = ""

Button3.Text = ""

Button4.Text = ""

Button5.Text = ""

Button6.Text = ""

Button7.Text = ""

Button8.Text = ""

Button9.Text = ""

End If



If Button1.Text = "O" And Button4.Text = "O" And Button7.Text = "O" Then

MsgBox("Player O wins!", MsgBoxStyle.Information)

Label4.Text += 1

Button1.Text = ""

Button2.Text = ""

Button3.Text = ""

Button4.Text = ""

Button5.Text = ""

Button6.Text = ""

Button7.Text = ""

Button8.Text = ""

Button9.Text = ""

End If



If Button1.Text = "O" And Button5.Text = "O" And Button9.Text = "O" Then

MsgBox("Player O wins!", MsgBoxStyle.Information)

Label4.Text += 1

Button1.Text = ""

Button2.Text = ""

Button3.Text = ""

Button4.Text = ""

Button5.Text = ""

Button6.Text = ""

Button7.Text = ""

Button8.Text = ""

Button9.Text = ""

End If



If Button2.Text = "O" And Button5.Text = "O" And Button8.Text = "O" Then

MsgBox("Player O wins!", MsgBoxStyle.Information)

Label4.Text += 1

Button1.Text = ""

Button2.Text = ""

Button3.Text = ""

Button4.Text = ""

Button5.Text = ""

Button6.Text = ""

Button7.Text = ""

Button8.Text = ""

Button9.Text = ""

End If



If Button3.Text = "O" And Button6.Text = "O" And Button9.Text = "O" Then

MsgBox("Player O wins!", MsgBoxStyle.Information)

Label4.Text += 1

Button1.Text = ""

Button2.Text = ""

Button3.Text = ""

Button4.Text = ""

Button5.Text = ""

Button6.Text = ""

Button7.Text = ""

Button8.Text = ""

Button9.Text = ""

End If



If Button3.Text = "O" And Button5.Text = "O" And Button7.Text = "O" Then

MsgBox("Player O wins!", MsgBoxStyle.Information)

Label4.Text += 1

Button1.Text = ""

Button2.Text = ""

Button3.Text = ""

Button4.Text = ""

Button5.Text = ""

Button6.Text = ""

Button7.Text = ""

Button8.Text = ""

Button9.Text = ""

End If



If Button4.Text = "O" And Button5.Text = "O" And Button6.Text = "O" Then

MsgBox("Player O wins!", MsgBoxStyle.Information)

Label4.Text += 1

Button1.Text = ""

Button2.Text = ""

Button3.Text = ""

Button4.Text = ""

Button5.Text = ""

Button6.Text = ""

Button7.Text = ""

Button8.Text = ""

Button9.Text = ""

End If



If Button7.Text = "O" And Button8.Text = "O" And Button9.Text = "O" Then

MsgBox("Player O wins!", MsgBoxStyle.Information)

Label4.Text += 1

Button1.Text = ""

Button2.Text = ""

Button3.Text = ""

Button4.Text = ""

Button5.Text = ""

Button6.Text = ""

Button7.Text = ""

Button8.Text = ""

Button9.Text = ""

End If



End Sub









</div>