Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > .NET Framework > Forum > ช่วยด้วยครับ รบกวนช่วยอธิบายให้หน่อยครับ เกมส์ OX VB ครับ



 

ช่วยด้วยครับ รบกวนช่วยอธิบายให้หน่อยครับ เกมส์ OX VB ครับ

 



Topic : 064563



โพสกระทู้ ( 22 )
บทความ ( 0 )



สถานะออฟไลน์
Facebook



OX

Code (VB 6)
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 เวอร์ชั่น 1.0 โดย ด.ช.ศิลป์ สัจจะวัฒนวิมล", 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 




กรุณาช่วยอธิบายหลักการ การทำงานของโค้ดแต่ล่ะบรรทัดให้ผมหน่อยครับ
ต้องการด่วนเลยครับ ถ้าไม่ได้ล่ะแย่แน่เลยครับ ต้องออกไปนำเสนอด้วย อิอิ

ช่วยหน่อยนะครับ


ขอบคุณโค้ดจาก http://www.vcharkarn.com/vcafe/34481



Tag : VBScript









ประวัติการแก้ไข
2011-08-10 21:01:47
Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2011-08-10 20:54:24 By : dragon_ball_king View : 4021 Reply : 3
 

 

No. 1



โพสกระทู้ ( 22 )
บทความ ( 0 )



สถานะออฟไลน์
Facebook

....








ประวัติการแก้ไข
2011-08-10 21:01:08
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-08-10 21:00:27 By : dragon_ball_king
 


 

No. 2



โพสกระทู้ ( 74,058 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook

จะไหวเหรอครับ หลายบรรทัดน่ะครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-08-10 23:05:10 By : webmaster
 

 

No. 3



โพสกระทู้ ( 22 )
บทความ ( 0 )



สถานะออฟไลน์
Facebook

ขอบคุณครับ ไม่เอาแล้วครับ เพื่อนผมเอาไปล่ะ ฮ่าๆๆๆ
หาใหม่ๆ

ใครพอมีโค้ดเกมส์ที่เป็น AI บ้างครับที่คล้ายๆกับตัวอย่างข้างต้น บ้างครับ ผมขอได้มั้ย อิอิ ส่งวันจันทร์แล้วซะด้วย ง่าๆๆ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-08-11 18:25:35 By : dragon_ball_king
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : ช่วยด้วยครับ รบกวนช่วยอธิบายให้หน่อยครับ เกมส์ OX VB ครับ
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 04
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่