PUBLIC z AS Integer 'Zahl der Züge
PUBLIC w AS String 'wer ist am Zug O oder x
PUBLIC SUB Form_Open()
ME.Text = "Tic Tac Toe"
ME.Center
Button1_Click
END
SUB gewonnen()
a AS Integer
a = 1
IF (Textbox1.Text = w AND Textbox2.Text = w AND Textbox3.Text = w) THEN a = 0
IF (Textbox4.Text = w AND Textbox5.Text = w AND Textbox6.Text = w) THEN a = 0
IF (Textbox7.Text = w AND Textbox8.Text = w AND Textbox9.Text = w) THEN a = 0
IF (Textbox1.Text = w AND Textbox4.Text = w AND Textbox7.Text = w) THEN a = 0
IF (Textbox2.Text = w AND Textbox5.Text = w AND Textbox8.Text = w) THEN a = 0
IF (Textbox3.Text = w AND Textbox6.Text = w AND Textbox9.Text = w) THEN a = 0
IF (Textbox1.Text = w AND Textbox5.Text = w AND Textbox9.Text = w) THEN a = 0
IF (Textbox3.Text = w AND Textbox5.Text = w AND Textbox7.Text = w) THEN a = 0
IF a = 0 THEN
TextArea1.Text = w & " hat gewonnen"
ENDIF
END
SUB wechsel()
INC z
IF z = 1 OR z = 3 OR z = 5 OR z = 7 OR z = 9 THEN
w = "X"
TextArea1.Text = "Am Zug ist O"
ENDIF
IF z = 2 OR z = 4 OR z = 6 OR z = 8 OR z = 10 THEN
w = "O"
TextArea1.Text = "Am Zug ist X"
ENDIF
TextArea2.Text = "Zug " & Str(z)
END
PUBLIC SUB TextBox1_DblClick()
IF TextBox1.Text = "" THEN
wechsel
textbox1.Text = w
gewonnen
ELSE
TextArea1.Text = "Schon belegt"
ENDIF
END
PUBLIC SUB Textbox2_DblClick()
IF textbox2.Text = "" THEN
wechsel
textbox2.Text = w
gewonnen
ELSE
TextArea1.Text = "Schon belegt"
ENDIF
END
PUBLIC SUB Textbox3_DblClick()
IF textbox3.Text = "" THEN
wechsel
textbox3.Text = w
gewonnen
ELSE
TextArea1.Text = "Schon belegt"
ENDIF
END
PUBLIC SUB Textbox4_DblClick()
IF textbox4.Text = "" THEN
wechsel
textbox4.Text = w
gewonnen
ELSE
TextArea1.Text = "Schon belegt"
ENDIF
END
PUBLIC SUB Textbox5_DblClick()
IF textbox5.Text = "" THEN
wechsel
textbox5.Text = w
gewonnen
ELSE
TextArea1.Text = "Schon belegt"
ENDIF
END
PUBLIC SUB Textbox6_DblClick()
IF textbox6.Text = "" THEN
wechsel
textbox6.Text = w
gewonnen
ELSE
TextArea1.Text = "Schon belegt"
ENDIF
END
PUBLIC SUB Textbox7_DblClick()
IF textbox7.Text = "" THEN
wechsel
textbox7.Text = w
gewonnen
ELSE
TextArea1.Text = "Schon belegt"
ENDIF
END
PUBLIC SUB Textbox8_DblClick()
IF textbox8.Text = "" THEN
wechsel
textbox8.Text = w
gewonnen
ELSE
TextArea1.Text = "Schon belegt"
ENDIF
END
PUBLIC SUB Textbox9_DblClick()
IF textbox9.Text = "" THEN
wechsel
textbox9.Text = w
gewonnen
ELSE
TextArea1.Text = "Schon belegt"
ENDIF
END
PUBLIC SUB Button1_Click()
'neues Spiel, alle Textfelder werden gelöscht, z (Zahl der Spielzüge) auf Null gesetzt
textbox1.Text = ""
textbox2.Text = ""
textbox3.Text = ""
textbox4.Text = ""
textbox5.Text = ""
textbox6.Text = ""
textbox7.Text = ""
textbox8.Text = ""
textbox9.Text = ""
z = 0
TextArea1.Text = "Am Zug ist X"
TextArea2.Text = "Zug 0"
END
PUBLIC SUB Button2_Click()
DIM msg AS String
msg = "Tic Tac Toe: Spielregeln\n"
msg = msg & "Mit der Maus (Doppelklick!) markiert der erste Spieler ein freies Feld.\n"
msg = msg & "Das Feld wird mit X gekennzeichnet.\n"
msg = msg & "Danach ist der Spielpartner dran.\n"
msg = msg & "Er bekommt O zugeordnet und klickt ein freies Feld an.\n"
msg = msg & "Gesetzt wird abwechselnd.\n"
msg = msg & "Sieger ist, wer drei gleiche Zeichen in einer Reihe setzen kann."
Message.Info( msg ,"OK")
END
PUBLIC SUB Button3_Click()
DIM msg AS String
msg = "Fragen zum Spiel\n"
msg = msg & "Gibt es ein Spiel mit weniger als 5 Zügen?\n"
msg = msg & "Gibt es ein Spiel mit mehr als 9 Zügen?\n"
msg = msg & "Gibt es für den Spieler, der beginnen darf,\n"
msg = msg & "eine optimale Gewinnstrategie?\n"
msg = msg & "Wo wurde dieses Spiel das erste Mal gespielt?\n"
msg = msg & "Wo wurde dieses Spiel das erste Mal beschrieben?\n"
msg = msg & "Antworten per email an: rho54@gmx.de"
Message.Info( msg ,"OK")
END
PUBLIC SUB Button4_Click()
ME.Close
END