Quantcast
Viewing all articles
Browse latest Browse all 15804

Issues with Basic Test Program

Hey everyone,

I have tried to program a simple game in Basic. The game which is called Tic tac toe with a multi-page query.
When starting the game I always get the error message Else without If.
I can't find the error.

The game field is 12 buttons from top left to bottom right. The button is called as name "lblspieler".

Can you help me further? Thanks.

Code:
Code:

Private Sub Command1_Click(Index As Integer)
If lblSpieler.Caption = "1" Then
  lblSpieler.Caption = "2"
Command1(Index).Caption = "X"
Command1(Index).Enabled = False
ElseIf lblSpieler.Caption = "2" Then
lblSpieler.Caption = "1"
Command1(Index).Caption = "O"
Command1(Index).Enabled = False

ElseIf Command1(0).Caption = "X" And Command1(1).Caption = "X" And Command1(2).Caption = "X" Then MsgBox "Spieler 1 hat gewonnen!"
Command1(Index).Enabled = False

ElseIf Command1(3).Caption = "O" And Command1(4).Caption = "O" And Command1(5).Caption = "O" Then MsgBox "Spieler 2 hat gewonnen!"
Command1(Index).Enabled = False

ElseIf Command1(6).Caption = "X" And Command1(7).Caption = "X" And Command1(8).Caption = "X" Then MsgBox "Spieler 1 hat gewonnen!"
Command1(Index).Enabled = False

ElseIf Command1(0).Caption = "O" And Command1(3).Caption = "O" And Command1(6).Caption = "O" Then MsgBox "Spieler 2 hat gewonnen!"
Command1(Index).Enabled = False

ElseIf Command1(1).Caption = "X" And Command1(4).Caption = "X" And Command1(7).Caption = "X" Then MsgBox "Spieler 1 hat gewonnen!"
Command1(Index).Enabled = False

ElseIf Command1(2).Caption = "O" And Command1(5).Caption = "O" And Command1(8).Caption = "O" Then MsgBox "Spieler 2 hat gewonnen!"
Command1(Index).Enabled = False

ElseIf Command1(0).Caption = "X" And Command1(4).Caption = "X" And Command1(8).Caption = "X" Then MsgBox "Spieler 1 hat gewonnen!"
Command1(Index).Enabled = False

ElseIf Command1(2).Caption = "O" And Command1(4).Caption = "O" And Command1(6).Caption = "O" Then MsgBox "Spieler 2 hat gewonnen!"
Command1(Index).Enabled = False
End If
End Sub

Image may be NSFW.
Clik here to view.
Name:  test.png
Views: 33
Size:  8.1 KB
Attached Images
Image may be NSFW.
Clik here to view.
 

Viewing all articles
Browse latest Browse all 15804

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>