ช่วยแก้โค้โปรแกรมให้หน่อยค่ะมันรันไม่ได้TOT
Dim b1, b2, b3, b4, b5, b6, b7, b8, b9 As Integer
Dim result As String
Sub checkO()
If Command1.Caption = "O" And Command2.Caption = "O" And Command3.Caption = "O" Then
Label1.Caption = " ¼ÙéàÅè¹·Õè 2 "
Option1.Enabled = False
Command4.Enabled = False
Command5.Enabled = False
Command6.Enabled = False
Command7.Enabled = False
Command8.Enabled = False
Command9.Enabled = False
ElseIf Command4.Caption = "O" And Command5.Caption = "O" And Command6.Caption = "O" Then
Label1.Caption = "¼ÙéàÅè¹·Õè 2 ª¹Ð"
Option1.Enabled = False
Command1.Enabled = False
Command2.Enabled = False
Command3.Enabled = False
Command7.Enabled = False
Command8.Enabled = False
Command9.Enabled = False
ElseIf Command7.Caption = "O" And Command8.Caption = "O" And Command9.Caption = "O" Then
Label1.Caption = "¼ÙéàÅè¹·Õè 2 ª¹Ð"
Option1.Enabled = False
Command1.Enabled = False
Command2.Enabled = False
Command3.Enabled = False
Command4.Enabled = False
Command5.Enabled = False
Command6.Enabled = False
ElseIf Command1.Caption = "O" And Command4.Caption = "O" And Command7.Caption = "O" Then
Label1.Caption = "¼ÙéàÅè¹·Õè 2 ª¹Ð"
Option1.Enabled = False
Command2.Enabled = False
Command3.Enabled = False
Command5.Enabled = False
Command6.Enabled = False
Command8.Enabled = False
Command9.Enabled = False
ElseIf Command2.Caption = "O" And Command5.Caption = "O" And Command8.Caption = "O" Then
Label1.Caption = "¼ÙéàÅè¹·Õè 2 ª¹Ð"
Option1.Enabled = False
Command1.Enabled = False
Command3.Enabled = False
Command4.Enabled = False
Command6.Enabled = False
Command7.Enabled = False
Command9.Enabled = False
ElseIf Command3.Caption = "O" And Command6.Caption = "O" And Command9.Caption = "O" Then
Label1.Caption = "¼ÙéàÅè¹·Õè 2 ª¹Ð"
Option1.Enabled = False
Command1.Enabled = False
Command2.Enabled = False
Command4.Enabled = False
Command5.Enabled = False
Command7.Enabled = False
Command8.Enabled = False
ElseIf Command1.Caption = "O" And Command5.Caption = "O" And Command9.Caption = "O" Then
Label1.Caption = "¼ÙéàÅè¹·Õè 2 ª¹Ð"
Option1.Enabled = False
Command2.Enabled = False
Command3.Enabled = False
Command4.Enabled = False
Command6.Enabled = False
Command7.Enabled = False
Command8.Enabled = False
ElseIf Command3.Caption = "O" And Command5.Caption = "O" And Command7.Caption = "O" Then
Label1.Caption = "¼ÙéàÅè¹·Õè 2 ª¹Ð"
Option1.Enabled = False
Command1.Enabled = False
Command2.Enabled = False
Command4.Enabled = False
Command6.Enabled = False
Command8.Enabled = False
Command9.Enabled = False
End If
End Sub
Sub checkX()
If Command1.Caption = "X" And Command2.Caption = "X" And Command3.Caption = "X" Then
Label1.Caption = "¼ÙéàÅè¹·Õè 1 ª¹Ð"
Option2.Enabled = False
Command4.Enabled = False
Command5.Enabled = False
Command6.Enabled = False
Command7.Enabled = False
Command8.Enabled = False
Command9.Enabled = False
ElseIf Command4.Caption = "X" And Command5.Caption = "X" And Command6.Caption = "X" Then
Label1.Caption = "¼ÙéàÅè¹·Õè 1 ª¹Ð"
Option2.Enabled = False
Command1.Enabled = False
Command2.Enabled = False
Command3.Enabled = False
Command7.Enabled = False
Command8.Enabled = False
Command9.Enabled = False
ElseIf Command7.Caption = "X" And Command8.Caption = "X" And Command9.Caption = "X" Then
Label1.Caption = "¼ÙéàÅè¹·Õè 1 ª¹Ð"
Option2.Enabled = False
Command1.Enabled = False
Command2.Enabled = False
Command3.Enabled = False
Command4.Enabled = False
Command5.Enabled = False
Command6.Enabled = False
ElseIf Command1.Caption = "X" And Command4.Caption = "X" And Command7.Caption = "X" Then
Label1.Caption = "¼ÙéàÅè¹·Õè 1 ª¹Ð"
Option2.Enabled = False
Command2.Enabled = False
Command3.Enabled = False
Command5.Enabled = False
Command6.Enabled = False
Command8.Enabled = False
Command9.Enabled = False
ElseIf Command2.Caption = "X" And Command5.Caption = "X" And Command8.Caption = "X" Then
Label1.Caption = "¼ÙéàÅè¹·Õè 1 ª¹Ð"
Option2.Enabled = False
Command1.Enabled = False
Command3.Enabled = False
Command4.Enabled = False
Command6.Enabled = False
Command7.Enabled = False
Command9.Enabled = False
ElseIf Command3.Caption = "X" And Command6.Caption = "X" And Command9.Caption = "X" Then
Label1.Caption = "¼ÙéàÅè¹·Õè 1 ª¹Ð"
Option2.Enabled = False
Command1.Enabled = False
Command2.Enabled = False
Command4.Enabled = False
Command5.Enabled = False
Command7.Enabled = False
Command8.Enabled = False
ElseIf Command1.Caption = "X" And Command5.Caption = "X" And Command9.Caption = "X" Then
Label1.Caption = "¼ÙéàÅè¹·Õè 1 ª¹Ð"
Option2.Enabled = False
Command2.Enabled = False
Command3.Enabled = False
Command4.Enabled = False
Command6.Enabled = False
Command7.Enabled = False
Command8.Enabled = False
ElseIf Command3.Caption = "X" And Command5.Caption = "X" And Command7.Caption = "X" Then
Label1.Caption = "¼ÙéàÅè¹·Õè 1 ª¹Ð"
Option2.Enabled = False
Command1.Enabled = False
Command2.Enabled = False
Command4.Enabled = False
Command6.Enabled = False
Command8.Enabled = False
Command9.Enabled = False
End If
End Sub
Sub checkdraw()
If Command1.Caption <> "" And Command2.Caption <> "" And Command3.Caption <> "" And Command4.Caption <> "" And Command5.Caption <> "" And Command6.Caption <> "" And Command7.Caption <> "" And Command8.Caption <> "" And Command9.Caption <> "" And Label1.Caption = "" Then
Label1.Caption = "àÊÁ͡ѹ"
Command1.Enabled = False
Command2.Enabled = False
Command3.Enabled = False
Command4.Enabled = False
Command5.Enabled = False
Command6.Enabled = False
Command7.Enabled = False
Command8.Enabled = False
Command9.Enabled = False
result = Label1.Caption
End If
End Sub
Private Sub Command1_Click()
If b1 = 0 Then
If Option1 = True Then
Command1.Caption = "X"
Option2 = True
Option1.Enabled = False
Option2.Enabled = True
Else
Command1.Caption = "O"
Option1 = True
Option2.Enabled = False
Option1.Enabled = True
End If
checkO
checkX
checkdraw
b1 = b1 + 1
result = Label1.Caption
Else
MsgBox "ªè͹Õéä´éÁÕ¡ÒáÒä»àÃÕºÃéÍÂáÅéÇ", vbCritical, "¼Ô´¾ÅÒ´"
End If
End Sub
Private Sub Command2_Click()
If b2 = 0 Then
If Option1 = True Then
Command2.Caption = "X"
Option2 = True
Option1.Enabled = False
Option2.Enabled = True
Else
Command2.Caption = "O"
Option1 = True
Option2.Enabled = False
Option1.Enabled = True
End If
checkO
checkX
checkdraw
b2 = b2 + 1
result = Label1.Caption
Else
MsgBox "ªè͹Õéä´éÁÕ¡ÒáÒä»àÃÕºÃéÍÂáÅéÇ", vbCritical, "¼Ô´¾ÅÒ´"
End If
End Sub
Private Sub Command3_Click()
If b3 = 0 Then
If Option1 = True Then
Command3.Caption = "X"
Option2 = True
Option1.Enabled = False
Option2.Enabled = True
Else
Command3.Caption = "O"
Option1 = True
Option2.Enabled = False
Option1.Enabled = True
End If
checkO
checkX
checkdraw
b3 = b3 + 1
result = Label1.Caption
Else
MsgBox "ªè͹Õéä´éÁÕ¡ÒáÒä»àÃÕºÃéÍÂáÅéÇ", vbCritical, "¼Ô´¾ÅÒ´"
End If
End Sub
Private Sub Command4_Click()
If b4 = 0 Then
If Option1 = True Then
Command4.Caption = "X"
Option2 = True
Option1.Enabled = False
Option2.Enabled = True
Else
Command4.Caption = "O"
Option1 = True
Option2.Enabled = False
Option1.Enabled = True
End If
checkO
checkX
checkdraw
b4 = b4 + 1
result = Label1.Caption
Else
MsgBox "ªè͹Õéä´éÁÕ¡ÒáÒä»àÃÕºÃéÍÂáÅéÇ", vbCritical, "¼Ô´¾ÅÒ´"
End If
End Sub
Private Sub Command5_Click()
If b5 = 0 Then
If Option1 = True Then
Command5.Caption = "X"
Option2 = True
Option1.Enabled = False
Option2.Enabled = True
Else
Command5.Caption = "O"
Option1 = True
Option2.Enabled = False
Option1.Enabled = True
End If
checkO
checkX
checkdraw
b5 = b5 + 1
result = Label1.Caption
Else
MsgBox "ªè͹Õéä´éÁÕ¡ÒáÒä»àÃÕºÃéÍÂáÅéÇ", vbCritical, "¼Ô´¾ÅÒ´"
End If
End Sub
Private Sub Command6_Click()
If b6 = 0 Then
If Option1 = True Then
Command6.Caption = "X"
Option2 = True
Option1.Enabled = False
Option2.Enabled = True
Else
Command6.Caption = "O"
Option1 = True
Option2.Enabled = False
Option1.Enabled = True
End If
checkO
checkX
checkdraw
b6 = b6 + 1
result = Label1.Caption
Else
MsgBox "ªè͹Õéä´éÁÕ¡ÒáÒä»àÃÕºÃéÍÂáÅéÇ", vbCritical, "¼Ô´¾ÅÒ´"
End If
End Sub
Private Sub Command7_Click()
If b7 = 0 Then
If Option1 = True Then
Command7.Caption = "X"
Option2 = True
Option1.Enabled = False
Option2.Enabled = True
Else
Command7.Caption = "O"
Option1 = True
Option2.Enabled = False
Option1.Enabled = True
End If
checkO
checkX
checkdraw
b7 = b7 + 1
result = Label1.Caption
Else
MsgBox "ªè͹Õéä´éÁÕ¡ÒáÒä»àÃÕºÃéÍÂáÅéÇ", vbCritical, "¼Ô´¾ÅÒ´"
End If
End Sub
Private Sub Command8_Click()
If b8 = 0 Then
If Option1 = True Then
Command8.Caption = "X"
Option2 = True
Option1.Enabled = False
Option2.Enabled = True
Else
Command8.Caption = "O"
Option1 = True
Option2.Enabled = False
Option1.Enabled = True
End If
checkO
checkX
checkdraw
b8 = b8 + 1
result = Label1.Caption
Else
MsgBox "ªè͹Õéä´éÁÕ¡ÒáÒä»àÃÕºÃéÍÂáÅéÇ", vbCritical, "¼Ô´¾ÅÒ´"
End If
End Sub
Private Sub Command9_Click()
If b9 = 0 Then
If Option1 = True Then
Command9.Caption = "X"
Option2 = True
Option1.Enabled = False
Option2.Enabled = True
Else
Command9.Caption = "O"
Option1 = True
Option2.Enabled = False
Option1.Enabled = True
End If
checkO
checkX
checkdraw
b9 = b9 + 1
result = Label1.Caption
Else
MsgBox "ªè͹Õéä´éÁÕ¡ÒáÒä»àÃÕºÃéÍÂáÅéÇ", vbCritical, "¼Ô´¾ÅÒ´"
End If
End Sub
Private Sub Form_Load()
Option1 = True
Option2.Enabled = False
End Sub
Private Sub mmabout_Click(Index As Integer)
MsgBox " à¡Á XO ", vbInformation, "à¡ÕèÂǡѺ"
End Sub
Private Sub mmexit_Click(Index As Integer)
Dim answer As Integer
answer = MsgBox("¤Ø³á¹èã¨ËÃ×ÍÇèÒ¨ÐÍÍ¡¨Ò¡â»Ãá¡ÃÁ", vbQuestion + vbOKCancel, "ÍÍ¡¨Ò¡â»Ãá¡ÃÁ")
If answer = 1 Then
End
End If
End Sub
Private Sub mmlastscore_Click(Index As Integer)
If result <> "" Then
MsgBox "¼Åã¹Ãͺ·Õè¼èÒ¹ÁÒ" + " " + result + " " + "¤èÐ/¤ÃѺ", vbInformation, "¼Åã¹Ãͺ·Õè¼èÒ¹ÁÒ"
Else
MsgBox "ÂÑäÁèÁÕ¡ÒÃàÃÔèÁàÅè¹à¡Á", vbInformation, "¼Åã¹Ãͺ·Õè¼èÒ¹ÁÒ"
End If
End Sub
Private Sub mmnew_Click(Index As Integer)
Command1.Caption = ""
Command2.Caption = ""
Command3.Caption = ""
Command4.Caption = ""
Command5.Caption = ""
Command6.Caption = ""
Command7.Caption = ""
Command8.Caption = ""
Command9.Caption = ""
Label1.Caption = ""
Option1.Enabled = True
Option2.Enabled = False
Option1 = True
b1 = 0
b2 = 0
b3 = 0
b4 = 0
b5 = 0
b6 = 0
b7 = 0
b8 = 0
b9 = 0
Command1.Enabled = True
Command2.Enabled = True
Command3.Enabled = True
Command4.Enabled = True
Command5.Enabled = True
Command6.Enabled = True
Command7.Enabled = True
Command8.Enabled = True
Command9.Enabled = True
End Sub
|