ทำไหมมันผิดครับพอดีพึงหัดใช่ หาวิธีไม่เจอจริงๆ ใช่ Microsoft Visual Basic 6.0

Dim a, b, c, d, e, f, g, h, i As Integer

Dim m As Integer

Dim n As Integer

Dim x As Integer

Sub checkWnner()

If a + b + c = 3 Then x = 10

If d + e + f = 3 Then x = 10

If g + h + i = 3 Then x = 10

If a + d + g = 3 Then x = 10

If b + e + h = 3 Then x = 10

If c + f + i = 3 Then x = 10

If a + e + i = 3 Then x = 10

If g + e + c = 3 Then x = 10

If a + b + c = 3 Then x = 10

If d + e + f = 3 Then x = 10

If g + h + i = 3 Then x = 10

If a + d + g = 3 Then x = 10

If b + e + h = 3 Then x = 10

If c + f + i = 3 Then x = 10

If a + e + i = 3 Then x = 10

If g + e + c = 3 Then x = 10

If n = 9 Then

If x <> 10 And x <> 11 Then x = 10

End If

Select Case x

Case 10

x = masbox(" O win", vbOKOnly, "result game")

Call Form_Load

Case 11

x = masbox(" X win", vbOKOnly, "result game")

Call Form_Load

Case 12

x = masbox(" àÊÁÍ win", vbOKOnly, "result game")

Call Form_Load

Case Else

End Select

End Sub

Private Sub command1_click()

Call checkplayer

a = m

If m = 0 Then Command1.Caption = "X"

If m = 1 Then Command1.Caption = "O"

Call checkwinner

End Sub

Private Sub Command2_Click()

Call checkplayer

b = m

If m = 0 Then Command2.Caption = "x"

If m = 1 Then Command2.Caption = "O"

Call checkwinner

End Sub

Private Sub Command3_Click()

Call checkplayer

c = m

If m = 0 Then Command3.Caption = "x"

If m = 1 Then Command3.Caption = "O"

Call checkwinner

End Sub

Private Sub Command4_Click()

Call checkplayer

d = m

If m = 0 Then Command4.Caption = "x"

If m = 1 Then Command4.Caption = "O"

Call checkwinner

End Sub

Private Sub Command5_Click()

Call checkplayer

e = m

If m = 0 Then Command5.Caption = "x"

If m = 1 Then Command5.Caption = "O"

Call checkwinner

End Sub

Private Sub Command6_Click()

Call checkplayer

f = m

If m = 0 Then Command6.Caption = "x"

If m = 1 Then Command6.Caption = "O"

Call checkwinner

End Sub

Private Sub Command7_Click()

Call checkplayer

g = m

If m = 0 Then Command7.Caption = "x"

If m = 1 Then Command7.Caption = "O"

Call checkwinner

End Sub

Private Sub Command8_Click()

Call checkplayer

h = m

If m = 0 Then Command8.Caption = "x"

If m = 1 Then Command8.Caption = "O"

Call checkwinner

End Sub

Private Sub Command9_Click()

Call checkplayer

i = m

If m = 0 Then Command9.Caption = "x"

If m = 1 Then Command9.Caption = "O"

Call checkwinner

End Sub

Private Sub Form_Load()

Form1.Caption = "tic toe Game"

Command1.FontSize = 20

Command1.FontBold = True

Command2.FontSize = 20

Command2.FontBold = True

Command3.FontSize = 20

Command3.FontBold = True

Command4.FontSize = 20

Command4.FontBold = True

Command5.FontSize = 20

Command5.FontBold = True

Command6.FontSize = 20

Command6.FontBold = True

Command7.FontSize = 20

Command7.FontBold = True

Command8.FontSize = 20

Command8.FontBold = True

Command9.FontSize = 20

Command9.FontBold = True

Command1.Caption = " "

Command2.Caption = " "

Command3.Caption = " "

Command4.Caption = " "

Command5.Caption = " "

Command6.Caption = " "

Command7.Caption = " "

Command8.Caption = " "

Command9.Caption = " "

n = 0

a = 5

b = 5

c = 5

d = 5

e = 5

f = 5

g = 5

h = 5

i = 5

x = 5

End Sub

Sub checkplayer()

n = n + 1

m = n Mod 2

End Sub

แสดงความคิดเห็น
Preview
โปรดศึกษาและยอมรับนโยบายข้อมูลส่วนบุคคลก่อนเริ่มใช้งาน อ่านเพิ่มเติมได้ที่นี่