Solved

Computer Player

Posted on 2001-06-13
18
233 Views
Last Modified: 2010-05-03
I am working on a game in VB.  I am a beginner, so I know this may sound cheezy.  I am making a tic-tac-toe based game.  I have it setup for one of the players to be the computer.  But I have a problem.  Sometime, when I go and take  turn, the computer will skip a turn.  And then, when I go again, it will take 2 turns to make up for it.  How do I solve this problem?  Here is the code I am using.

If Player = 1 Then
Image10.Picture = X.Picture
Call CheckWin
Player = 2
End If
If Player = 2 Then
Call ComputerMove
Call CheckWin
Player = 1
End If
End Sub
0
Comment
Question by:paulzeb
  • 7
  • 3
  • 3
  • +4
18 Comments
 
LVL 1

Accepted Solution

by:
manno earned 100 total points
ID: 6186273
You are setting Player to 2, then testing whether it's = 2

You need an exit sub or an else somewhere!
0
 
LVL 3

Expert Comment

by:Maxim10553
ID: 6186289
what do the functions checkwin and computermove look like? post that code also
0
 

Author Comment

by:paulzeb
ID: 6186326
Those are not the codes I a having problems with.  I just need to fix this one.
0
 
LVL 38

Expert Comment

by:PaulHews
ID: 6186372
Where is this code?
Is it in a click event somewhere?
0
 

Author Comment

by:paulzeb
ID: 6186378
I cleaned my code up a little, but I am still having the same problem.  Here is what my new code looks like.

If Player = 1 Then
Image10.Picture = X.Picture
Call CheckWin
Player = 2
End If
Call ComputerMove
Call CheckWin
Player = 1
End Sub
0
 

Author Comment

by:paulzeb
ID: 6186386
The code above is the code I have set for when a player clicksan empty box.
0
 
LVL 38

Expert Comment

by:PaulHews
ID: 6186448
You could try this if you have a re-entrancy problem.

'At general declaration level
private mbBusy as boolean

'In sub

If mbBusy Then exit sub
mbBusy = True
If Player = 1 Then
Image10.Picture = X.Picture
Call CheckWin
Player = 2
End If
Call ComputerMove
Call CheckWin
Player = 1
mbBusy = False

End Sub

Also, how do handle CheckWin to prevent it from re-entering the code shown if there is a win situation from the player?
0
 

Author Comment

by:paulzeb
ID: 6186609
I tried that code, and it does the same thing.
0
 
LVL 3

Expert Comment

by:Maxim10553
ID: 6186662
If Player = 1 Then
   Image10.Picture = X.Picture
   Call CheckWin
   Player = 2
else
   Call ComputerMove
   Call CheckWin
   Player = 1
End If

 
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 

Author Comment

by:paulzeb
ID: 6186766
I tried that code, but it seemed to not work as well.
0
 
LVL 38

Expert Comment

by:PaulHews
ID: 6186833
Try tracing through your code.  You might find the problem that way.  Otherwise we need to see all the extra code in order to help.
0
 
LVL 22

Expert Comment

by:rspahitz
ID: 6189049
If the above code is not working after fixed, then the problem must be in your subroutines, so check ComputerMove or CheckWin to ensure that it is not inadvertently recursing on itself.

Also, you may want to avoid using Player as a global variable and keep it local, then explicitly pass it to the routines as needed (ByVal if it should not change.)

 
0
 

Author Comment

by:paulzeb
ID: 6189066
This is my entire code:

Dim Player As Integer 'Players turn 1 - player1, 2 - player2
Private Sub Form_Load()
X.Visible = False
O.Visible = False
Player = 1
End Sub
Private Sub Clear()
Set Image2.Picture = Nothing
Set Image3.Picture = Nothing
Set Image4.Picture = Nothing
Set Image5.Picture = Nothing
Set Image6.Picture = Nothing
Set Image7.Picture = Nothing
Set Image8.Picture = Nothing
Set Image9.Picture = Nothing
Set Image10.Picture = Nothing
Set Image11.Picture = Nothing
Set Image12.Picture = Nothing
Set Image13.Picture = Nothing
Set Image14.Picture = Nothing
Set Image15.Picture = Nothing
Set Image16.Picture = Nothing
Set Image17.Picture = Nothing
Set Image18.Picture = Nothing
Set Image19.Picture = Nothing
Set Image20.Picture = Nothing
Set Image21.Picture = Nothing
Set Image22.Picture = Nothing
Set Image23.Picture = Nothing
Set Image24.Picture = Nothing
Set Image25.Picture = Nothing
Set Image26.Picture = Nothing
Player = 1
End Sub
Private Sub Image10_Click()
If Player = 1 Then
Image10.Picture = X.Picture
Call CheckWin
Player = 2
End If
Call ComputerMove
Call CheckWin
Player = 1
End Sub

Private Sub Image11_Click()
If Player = 1 Then
Image11.Picture = X.Picture
Call CheckWin
Player = 2
End If
Call ComputerMove
Call CheckWin
Player = 1
End Sub

Private Sub Image12_Click()
If Player = 1 Then
Image12.Picture = X.Picture
Call CheckWin
End If
Call ComputerMove
Call CheckWin
Player = 1
End Sub

Private Sub Image13_Click()
If Player = 1 Then
Image13.Picture = X.Picture
Call CheckWin
End If
Call ComputerMove
Call CheckWin
Player = 1
End Sub

Private Sub Image14_Click()
If Player = 1 Then
Image14.Picture = X.Picture
Call CheckWin
End If
Call ComputerMove
Call CheckWin
Player = 1
End Sub

Private Sub Image15_Click()
If Player = 1 Then
Image15.Picture = X.Picture
Call CheckWin
End If
Call ComputerMove
Call CheckWin
Player = 1
End Sub

Private Sub Image16_Click()
If Player = 1 Then
Image16.Picture = X.Picture
Call CheckWin
End If
Call ComputerMove
Call CheckWin
Player = 1
End Sub

Private Sub Image17_Click()
If Player = 1 Then
Image17.Picture = X.Picture
Call CheckWin
End If
Call ComputerMove
Call CheckWin
Player = 1
End Sub

Private Sub Image18_Click()
If Player = 1 Then
Image18.Picture = X.Picture
Call CheckWin
End If
Call ComputerMove
Call CheckWin
Player = 1
End Sub

Private Sub Image19_Click()
If Player = 1 Then
Image19.Picture = X.Picture
Call CheckWin
End If
Call ComputerMove
Call CheckWin
Player = 1
End Sub

Private Sub Image2_Click()
If Player = 1 Then
Image2.Picture = X.Picture
Call CheckWin
End If
Call ComputerMove
Call CheckWin
Player = 1
End Sub

Private Sub Image20_Click()
If Player = 1 Then
Image20.Picture = X.Picture
Call CheckWin
End If
Call ComputerMove
Call CheckWin
Player = 1
End Sub

Private Sub Image21_Click()
If Player = 1 Then
Image21.Picture = X.Picture
Call CheckWin
End If
Call ComputerMove
Call CheckWin
Player = 1
End Sub

Private Sub Image22_Click()
If Player = 1 Then
Image22.Picture = X.Picture
Call CheckWin
End If
Call ComputerMove
Call CheckWin
Player = 1
End Sub

Private Sub Image23_Click()
If Player = 1 Then
Image23.Picture = X.Picture
Call CheckWin
End If
Call ComputerMove
Call CheckWin
Player = 1
End Sub

Private Sub Image24_Click()
If Player = 1 Then
Image24.Picture = X.Picture
Call CheckWin
End If
Call ComputerMove
Call CheckWin
Player = 1
End Sub

Private Sub Image25_Click()
If Player = 1 Then
Image25.Picture = X.Picture
Call CheckWin
End If
Call ComputerMove
Call CheckWin
Player = 1
End Sub

Private Sub Image26_Click()
If Player = 1 Then
Image26.Picture = X.Picture
Call CheckWin
End If
Call ComputerMove
Call CheckWin
Player = 1
End Sub

Private Sub Image3_Click()
If Player = 1 Then
Image3.Picture = X.Picture
Call CheckWin
End If
Call ComputerMove
Call CheckWin
Player = 1
End Sub

Private Sub Image4_Click()
If Player = 1 Then
Image4.Picture = X.Picture
Call CheckWin
End If
Call ComputerMove
Call CheckWin
Player = 1
End Sub

Private Sub Image5_Click()
If Player = 1 Then
Image5.Picture = X.Picture
Call CheckWin
End If
Call ComputerMove
Call CheckWin
Player = 1
End Sub

Private Sub Image6_Click()
If Player = 1 Then
Image6.Picture = X.Picture
Call CheckWin
End If
Call ComputerMove
Call CheckWin
Player = 1
End Sub

Private Sub Image7_Click()
If Player = 1 Then
Image7.Picture = X.Picture
Call CheckWin
End If
Call ComputerMove
Call CheckWin
Player = 1
End Sub

Private Sub Image8_Click()
If Player = 1 Then
Image8.Picture = X.Picture
Call CheckWin
End If
Call ComputerMove
Call CheckWin
Player = 1
End Sub

Private Sub Image9_Click()
If Player = 1 Then
Image9.Picture = X.Picture
Call CheckWin
End If
Call ComputerMove
Call CheckWin
Player = 1
End Sub

Private Sub mnuExit_Click(Index As Integer)
Unload Me
End Sub

Private Sub mnuNew_Click(Index As Integer)
Call Clear
End Sub
Private Sub CheckWin()
If Image2.Picture = X And Image3.Picture = X And Image4.Picture = X And Image5.Picture = X Then
Call MsgBox
End If
If Image2.Picture = X And Image8.Picture = X And Image14.Picture = X And Image20.Picture = X Then
Call MsgBox
End If
If Image2.Picture = X And Image7.Picture = X And Image12.Picture = X And Image17.Picture = X Then
Call MsgBox
End If
If Image3.Picture = X And Image4.Picture = X And Image5.Picture = X And Image6.Picture = X Then
Call MsgBox
End If
If Image3.Picture = X And Image9.Picture = X And Image15.Picture = X And Image21.Picture = X Then
Call MsgBox
End If
If Image3.Picture = X And Image8.Picture = X And Image13.Picture = X And Image18.Picture = X Then
Call MsgBox
End If
If Image4.Picture = X And Image9.Picture = X And Image14.Picture = X And Image19.Picture = X Then
Call MsgBox
End If
If Image5.Picture = X And Image10.Picture = X And Image15.Picture = X And Image20.Picture = X Then
Call MsgBox
End If
If Image5.Picture = X And Image9.Picture = X And Image13.Picture = X And Image17.Picture = X Then
Call MsgBox
End If
If Image6.Picture = X And Image11.Picture = X And Image16.Picture = X And Image21.Picture = X Then
Call MsgBox
End If
If Image6.Picture = X And Image10.Picture = X And Image14.Picture = X And Image18.Picture = X Then
Call MsgBox
End If
If Image7.Picture = X And Image8.Picture = X And Image9.Picture = X And Image10.Picture = X Then
Call MsgBox
End If
If Image7.Picture = X And Image13.Picture = X And Image19.Picture = X And Image25.Picture = X Then
Call MsgBox
End If
If Image7.Picture = X And Image12.Picture = X And Image17.Picture = X And Image22.Picture = X Then
Call MsgBox
End If
If Image8.Picture = X And Image9.Picture = X And Image10.Picture = X And Image11.Picture = X Then
Call MsgBox
End If
If Image8.Picture = X And Image14.Picture = X And Image20.Picture = X And Image26.Picture = X Then
Call MsgBox
End If
If Image8.Picture = X And Image13.Picture = X And Image18.Picture = X And Image23.Picture = X Then
Call MsgBox
End If
If Image9.Picture = X And Image14.Picture = X And Image19.Picture = X And Image24.Picture = X Then
Call MsgBox
End If
If Image10.Picture = X And Image15.Picture = X And Image20.Picture = X And Image25.Picture = X Then
Call MsgBox
End If
If Image10.Picture = X And Image14.Picture = X And Image18.Picture = X And Image22.Picture = X Then
Call MsgBox
End If
If Image11.Picture = X And Image16.Picture = X And Image21.Picture = X And Image26.Picture = X Then
Call MsgBox
End If
If Image11.Picture = X And Image15.Picture = X And Image19.Picture = X And Image23.Picture = X Then
Call MsgBox
End If
If Image12.Picture = X And Image13.Picture = X And Image14.Picture = X And Image15.Picture = X Then
Call MsgBox
End If
If Image13.Picture = X And Image14.Picture = X And Image15.Picture = X And Image16.Picture = X Then
Call MsgBox
End If
If Image17.Picture = X And Image18.Picture = X And Image19.Picture = X And Image20.Picture = X Then
Call MsgBox
End If
If Image18.Picture = X And Image19.Picture = X And Image20.Picture = X And Image21.Picture = X Then
Call MsgBox
End If
If Image22.Picture = X And Image23.Picture = X And Image24.Picture = X And Image25.Picture = X Then
Call MsgBox
End If
If Image23.Picture = X And Image24.Picture = X And Image25.Picture = X And Image26.Picture = X Then
Call MsgBox
End If
If Image2.Picture = O And Image3.Picture = O And Image4.Picture = O And Image5.Picture = O Then
Call MsgBox2
End If
If Image2.Picture = O And Image8.Picture = O And Image14.Picture = O And Image20.Picture = O Then
Call MsgBox2
End If
If Image2.Picture = O And Image7.Picture = O And Image12.Picture = O And Image17.Picture = O Then
Call MsgBox2
End If
If Image3.Picture = O And Image4.Picture = O And Image5.Picture = O And Image6.Picture = O Then
Call MsgBox2
End If
If Image3.Picture = O And Image9.Picture = O And Image15.Picture = O And Image21.Picture = O Then
Call MsgBox2
End If
If Image3.Picture = O And Image8.Picture = O And Image13.Picture = O And Image18.Picture = O Then
Call MsgBox2
End If
If Image4.Picture = O And Image9.Picture = O And Image14.Picture = O And Image19.Picture = O Then
Call MsgBox2
End If
If Image5.Picture = O And Image10.Picture = O And Image15.Picture = O And Image20.Picture = O Then
Call MsgBox2
End If
If Image5.Picture = O And Image9.Picture = O And Image13.Picture = O And Image17.Picture = O Then
Call MsgBox2
End If
If Image6.Picture = O And Image11.Picture = O And Image16.Picture = O And Image21.Picture = O Then
Call MsgBox2
End If
If Image6.Picture = O And Image10.Picture = O And Image14.Picture = O And Image18.Picture = O Then
Call MsgBox2
End If
If Image7.Picture = O And Image8.Picture = O And Image9.Picture = O And Image10.Picture = O Then
Call MsgBox2
End If
If Image7.Picture = O And Image13.Picture = O And Image19.Picture = O And Image25.Picture = O Then
Call MsgBox2
End If
If Image7.Picture = O And Image12.Picture = O And Image17.Picture = O And Image22.Picture = O Then
Call MsgBox2
End If
If Image8.Picture = O And Image9.Picture = O And Image10.Picture = O And Image11.Picture = O Then
Call MsgBox2
End If
If Image8.Picture = O And Image14.Picture = O And Image20.Picture = O And Image26.Picture = O Then
Call MsgBox2
End If
If Image8.Picture = O And Image13.Picture = O And Image18.Picture = O And Image23.Picture = O Then
Call MsgBox2
End If
If Image9.Picture = O And Image14.Picture = O And Image19.Picture = O And Image24.Picture = O Then
Call MsgBox2
End If
If Image10.Picture = O And Image15.Picture = O And Image20.Picture = O And Image25.Picture = O Then
Call MsgBox2
End If
If Image10.Picture = O And Image14.Picture = O And Image18.Picture = O And Image22.Picture = O Then
Call MsgBox2
End If
If Image11.Picture = O And Image16.Picture = O And Image21.Picture = O And Image26.Picture = O Then
Call MsgBox2
End If
If Image11.Picture = O And Image15.Picture = O And Image19.Picture = O And Image23.Picture = O Then
Call MsgBox2
End If
If Image12.Picture = O And Image13.Picture = O And Image14.Picture = O And Image15.Picture = O Then
Call MsgBox2
End If
If Image13.Picture = O And Image14.Picture = O And Image15.Picture = O And Image16.Picture = O Then
Call MsgBox2
End If
If Image17.Picture = O And Image18.Picture = O And Image19.Picture = O And Image20.Picture = O Then
Call MsgBox2
End If
If Image18.Picture = O And Image19.Picture = O And Image20.Picture = O And Image21.Picture = O Then
Call MsgBox2
End If
If Image22.Picture = O And Image23.Picture = O And Image24.Picture = O And Image25.Picture = O Then
Call MsgBox2
End If
If Image23.Picture = O And Image24.Picture = O And Image25.Picture = O And Image26.Picture = O Then
Call MsgBox2
End If
End Sub
Public Sub MsgBox()
Form2.Show
Call Clear
End Sub
Public Sub MsgBox2()
Form3.Show
Call Clear
End Sub
Private Sub ComputerMove()
Call CheckWin
Call CheckBlock
Call Random
End Sub
Private Sub Random()
R = Int(25 - 1 + 1) * Rnd + 1
End Sub
Private Sub CheckBlock()
If Image2.Picture = X And Image3.Picture = X And Image4.Picture = X Then Image5.Picture = O
If Image2.Picture = X And Image3.Picture = X And Image5.Picture = X Then Image4.Picture = O
If Image2.Picture = X And Image4.Picture = X And Image5.Picture = X Then Image3.Picture = O
If Image2.Picture = X And Image8.Picture = X And Image14.Picture = X Then Image20.Picture = O
If Image2.Picture = X And Image8.Picture = X And Image20.Picture = X Then Image14.Picture = O
If Image2.Picture = X And Image14.Picture = X And Image20.Picture = X Then Image8.Picture = O
If Image2.Picture = X And Image7.Picture = X And Image12.Picture = X Then Image17.Picture = O
If Image2.Picture = X And Image7.Picture = X And Image17.Picture = X Then Image12.Picture = O
If Image2.Picture = X And Image12.Picture = X And Image17.Picture = X Then Image7.Picture = O
If Image3.Picture = X And Image4.Picture = X And Image5.Picture = X Then Image6.Picture = O
If Image3.Picture = X And Image4.Picture = X And Image6.Picture = X Then Image5.Picture = O
If Image3.Picture = X And Image5.Picture = X And Image6.Picture = X Then Image4.Picture = O
If Image3.Picture = X And Image4.Picture = X Then Image5.Picture = O
If Image3.Picture = X And Image9.Picture = X And Image15.Picture = X Then Image21.Picture = O
If Image3.Picture = X And Image15.Picture = X And Image21.Picture = X Then Image9.Picture = O
If Image3.Picture = X And Image9.Picture = X And Image21.Picture = X Then Image15.Picture = O
If Image3.Picture = X And Image8.Picture = X And Image13.Picture = X Then Image18.Picture = O
If Image3.Picture = X And Image8.Picture = X And Image18.Picture = X Then Image13.Picture = O
If Image3.Picture = X And Image13.Picture = X And Image18.Picture = X Then Image8.Picture = O
If Image4.Picture = X And Image5.Picture = X And Image6.Picture = X Then Image3.Picture = O
If Image4.Picture = X And Image9.Picture = X And Image14.Picture = X Then Image19.Picture = O
If Image4.Picture = X And Image14.Picture = X And Image19.Picture = X Then Image9.Picture = O
If Image4.Picture = X And Image9.Picture = X And Image19.Picture = X Then Image14.Picture = O
If Image4.Picture = X And Image5.Picture = X Then Image3.Picture = O
If Image5.Picture = X And Image10.Picture = X And Image15.Picture = X Then Image20.Picture = O
If Image5.Picture = X And Image15.Picture = X And Image20.Picture = X Then Image10.Picture = O
If Image5.Picture = X And Image10.Picture = X And Image20.Picture = X Then Image15.Picture = O
If Image5.Picture = X And Image9.Picture = X And Image13.Picture = X Then Image17.Picture = O
If Image5.Picture = X And Image13.Picture = X And Image17.Picture = X Then Image9.Picture = O
If Image5.Picture = X And Image9.Picture = X And Image17.Picture = X Then Image13.Picture = O
If Image6.Picture = X And Image11.Picture = X And Image16.Picture = X Then Image21.Picture = O
If Image6.Picture = X And Image16.Picture = X And Image21.Picture = X Then Image11.Picture = O
If Image6.Picture = X And Image11.Picture = X And Image21.Picture = X Then Image16.Picture = O
If Image6.Picture = X And Image10.Picture = X And Image14.Picture = X Then Image18.Picture = O
If Image6.Picture = X And Image10.Picture = X And Image18.Picture = X Then Image14.Picture = O
If Image6.Picture = X And Image14.Picture = X And Image18.Picture = X Then Image10.Picture = O
If Image7.Picture = X And Image8.Picture = X And Image9.Picture = X Then Image10.Picture = O
If Image7.Picture = X And Image8.Picture = X And Image10.Picture = X Then Image8.Picture = O
If Image7.Picture = X And Image8.Picture = X And Image10.Picture = X Then Image9.Picture = O
If Image7.Picture = X And Image13.Picture = X And Image19.Picture = X Then Image25.Picture = O
If Image7.Picture = X And Image13.Picture = X And Image25.Picture = X Then Image19.Picture = O
If Image7.Picture = X And Image19.Picture = X And Image25.Picture = X Then Image13.Picture = O
If Image7.Picture = X And Image12.Picture = X And Image17.Picture = X Then Image22.Picture = O
If Image7.Picture = X And Image12.Picture = X And Image22.Picture = X Then Image17.Picture = O
If Image7.Picture = X And Image17.Picture = X And Image22.Picture = X Then Image12.Picture = O
If Image7.Picture = X And Image12.Picture = X Then Image2.Picture = O
If Image8.Picture = X And Image9.Picture = X Then Image10.Picture = O
If Image8.Picture = X And Image9.Picture = X And Image10.Picture = X Then Image11.Picture = O
If Image8.Picture = X And Image10.Picture = X And Image11.Picture = X Then Image9.Picture = O
If Image8.Picture = X And Image9.Picture = X And Image11.Picture = X Then Image10.Picture = O
If Image8.Picture = X And Image14.Picture = X And Image20.Picture = X Then Image26.Picture = O
If Image8.Picture = X And Image20.Picture = X And Image26.Picture = X Then Image14.Picture = O
If Image8.Picture = X And Image14.Picture = X And Image26.Picture = X Then Image20.Picture = O
If Image8.Picture = X And Image13.Picture = X And Image18.Picture = X Then Image23.Picture = O
If Image8.Picture = X And Image18.Picture = X And Image23.Picture = X Then Image13.Picture = O
If Image8.Picture = X And Image18.Picture = X And Image23.Picture = X Then Image18.Picture = O
If Image8.Picture = X And Image13.Picture = X Then Image18.Picture = O
If Image8.Picture = X And Image14.Picture = X Then Image20.Picture = O
If Image9.Picture = X And Image10.Picture = X And Image11.Picture = X Then Image8.Picture = O
If Image9.Picture = X And Image15.Picture = X And Image21.Picture = X Then Image3.Picture = O
If Image9.Picture = X And Image14.Picture = X Then Image19.Picture = O
If Image9.Picture = X And Image13.Picture = X And Image17.Picture = X Then Image5.Picture = O
If Image9.Picture = X And Image14.Picture = X And Image24.Picture = X Then Image19.Picture = O
If Image9.Picture = X And Image19.Picture = X And Image24.Picture = X Then Image14.Picture = O
If Image9.Picture = X And Image10.Picture = X Then Image8.Picture = O
If Image9.Picture = X And Image15.Picture = X Then Image21.Picture = O
If Image9.Picture = X And Image13.Picture = X Then Image5.Picture = O
If Image10.Picture = X And Image15.Picture = X Then Image20.Picture = O
If Image10.Picture = X And Image20.Picture = X And Image25.Picture = X Then Image15.Picture = O
If Image10.Picture = X And Image15.Picture = X And Image25.Picture = X Then Image20.Picture = O
If Image10.Picture = X And Image14.Picture = X Then Image18.Picture = O
If Image10.Picture = X And Image18.Picture = X And Image22.Picture = X Then Image14.Picture = O
If Image11.Picture = X And Image16.Picture = X Then Image21.Picture = O
If Image11.Picture = X And Image21.Picture = X Then Image16.Picture = O
If Image11.Picture = X And Image21.Picture = X And Image26.Picture = X Then Image16.Picture = O
If Image11.Picture = X And Image16.Picture = X And Image26.Picture = X Then Image21.Picture = O
If Image11.Picture = X And Image15.Picture = X And Image19.Picture = X Then Image23.Picture = O
If Image11.Picture = X And Image19.Picture = X And Image23.Picture = X Then Image15.Picture = O
If Image11.Picture = X And Image15.Picture = X And Image23.Picture = X Then Image19.Picture = O
If Image12.Picture = X And Image13.Picture = X And Image14.Picture = X Then Image15.Picture = O
If Image12.Picture = X And Image17.Picture = X Then Image7.Picture = O
If Image12.Picture = X And Image17.Picture = X And Image22.Picture = X Then Image7.Picture = O
If Image13.Picture = X And Image14.Picture = X Then Image15.Picture = O
If Image13.Picture = X And Image14.Picture = X And Image15.Picture = X Then Image16.Picture = O
If Image13.Picture = X And Image18.Picture = X Then Image8.Picture = O
If Image13.Picture = X And Image19.Picture = X Then Image7.Picture = O
If Image13.Picture = X And Image19.Picture = X And Image25.Picture = X Then Image7.Picture = O
If Image13.Picture = X And Image18.Picture = X And Image23.Picture = X Then Image8.Picture = O
If Image14.Picture = X And Image15.Picture = X Then Image13.Picture = O
If Image14.Picture = X And Image15.Picture = X And Image16.Picture = X Then Image13.Picture = O
If Image14.Picture = X And Image20.Picture = X And Image26.Picture = X Then Image8.Picture = O
If Image14.Picture = X And Image19.Picture = X And Image24.Picture = X Then Image9.Picture = O
If Image14.Picture = X And Image18.Picture = X And Image22.Picture = X Then Image10.Picture = O
If Image14.Picture = X And Image18.Picture = X Then Image10.Picture = O
If Image14.Picture = X And Image19.Picture = X Then Image9.Picture = O
If Image14.Picture = X And Image20.Picture = X Then Image8.Picture = O
If Image15.Picture = X And Image20.Picture = X And Image25.Picture = X Then Image10.Picture = O
If Image15.Picture = X And Image19.Picture = X And Image23.Picture = X Then Image11.Picture = O
If Image15.Picture = X And Image20.Picture = X Then Image10.Picture = O
If Image15.Picture = X And Image19.Picture = X Then Image11.Picture = O
If Image16.Picture = X And Image21.Picture = X And Image26.Picture = X Then Image11.Picture = O
If Image16.Picture = X And Image21.Picture = X Then Image11.Picture = O
If Image17.Picture = X And Image18.Picture = X And Image19.Picture = X Then Image20.Picture = O
If Image18.Picture = X And Image19.Picture = X Then Image20.Picture = O
If Image18.Picture = X And Image19.Picture = X And Image20.Picture = X Then Image21.Picture = O
If Image19.Picture = X And Image20.Picture = X And Image21.Picture = X Then Image18.Picture = O
If Image22.Picture = X And Image23.Picture = X And Image24.Picture = X Then Image25.Picture = O
If Image23.Picture = X And Image24.Picture = X And Image25.Picture = X Then Image26.Picture = O
If Image23.Picture = X And Image24.Picture = X Then Image25.Picture = O
If Image22.Picture = X And Image24.Picture = X And Image25.Picture = X Then Image23.Picture = O
If Image22.Picture = X And Image23.Picture = X And Image25.Picture = X Then Image24.Picture = O
If Image23.Picture = X And Image25.Picture = X And Image26.Picture = X Then Image24.Picture = O
If Image23.Picture = X And Image24.Picture = X And Image26.Picture = X Then Image25.Picture = O
End Sub
0
 
LVL 22

Expert Comment

by:rspahitz
ID: 6189069
Ouch!  Definitely time to read up on control arrays.
0
 

Author Comment

by:paulzeb
ID: 6189073
i know, but i want to fix this computer player problem
0
 
LVL 22

Expert Comment

by:rspahitz
ID: 6191794
Just a hunch...change:

If Player = 1 Then
Image10.Picture = X.Picture
Call CheckWin
Player = 2
End If
Call ComputerMove
Call CheckWin
Player = 1
End Sub

to:

If Player = 1 Then
Image10.Picture = X.Picture
Call CheckWin
Player = 2
End If
Call ComputerMove
'Call CheckWin
Player = 1
End Sub

Since ComputerMove already runs CheckWin, the second call may be creating the problem.

And seriously, if you convert everything to arrays, 85% of your code will go away and it will be much easier to read and debug.
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7136042
Hi paulzeb,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will suggest to:

    Accept manno's comment(s) as an answer.

paulzeb, if you think your question was not answered at all or if you need help, you can simply post a new comment here.  Community Support moderators will follow up.

EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer
0
 
LVL 1

Expert Comment

by:Computer101
ID: 7168454
Comment from expert accepted as answer

Computer101
E-E Moderator
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now