Looping to see if something = something(resolved)
Hello, I'm working on a concentration game, and i'm trying to make the function that will tell if the user matches the flags or does not. So far, I've got it can only tell if they do not match them, but in my loop, it will only work if they click a 3, then a 4. It won't work if they click a 4, and then a 3.
Code:
VB Code:
Dim i As Integer
clickcount = clickcount + 1
lblCover(Index).Visible = False
For i = 0 To 15
If lblCover(i).Visible = False Then
If clickcount = 2 Then
picSecond.Picture = imgPicture(i).Picture
Else
picFirst.Picture = imgPicture(i).Picture
End If
End If
Next i
Call CheckMatch
Re: Looping to see if something = something
paralinx,
A better explaination is needed. Cannot make out what you are attempting to do in this routine.
Re: Looping to see if something = something
I'd have to see your Match routine, but I think you could use the .TAG property of the pictureboxes to store what is in them. Just use the picture number. Then, you could match easily.
Re: Looping to see if something = something
VB Code:
Dim i As Integer
Static clickcount As Integer
clickcount = clickcount + 1
lblCover(Index).Visible = False
For i = 0 To 15
If lblCover(i).Visible = False Then
If clickcount = 2 Then
picSecond.Picture = imgPicture(i).Picture
clickcount = 0 ' reset
Else
picFirst.Picture = imgPicture(i).Picture
End If
End If
Next i
Call CheckMatch
Re: Looping to see if something = something
Quote:
Originally Posted by randem
paralinx,
A better explaination is needed. Cannot make out what you are attempting to do in this routine.
well, I explained it the best I could, it really doesn't help when all you post is "explain it better"
Re: Looping to see if something = something
Heres what I meant.
VB Code:
Dim i As Integer
Static clickcount As Integer
clickcount = clickcount + 1
lblCover(Index).Visible = False
For i = 0 To 15
If lblCover(i).Visible = False Then
If clickcount = 2 Then
picSecond.Picture = imgPicture(i).Picture
picSecond.tag = i
clickcount = 0 ' reset
Else
picFirst.Picture = imgPicture(i).Picture
picFirst.tag = i
End If
End If
Next i
Call CheckMatch
' if picFirst.tag = picSecond.tag then pictures are the same
Re: Looping to see if something = something
Quote:
Originally Posted by dglienna
I'd have to see your Match routine, but I think you could use the .TAG property of the pictureboxes to store what is in them. Just use the picture number. Then, you could match easily.
my match function is very dumb, but it works somehow. How would I use the .TAG of the images to see if the pictures match?
Re: Looping to see if something = something
See post #6. Use the picture index as the tag. :)
Re: Looping to see if something = something
I'm trying to use this, but it is not working here is my code
VB Code:
Private Sub lblCover_Click(Index As Integer)
Dim i As Integer
clickcount = clickcount + 1
lblCover(Index).Visible = False
For i = 0 To 15
If lblCover(i).Visible = False Then
If clickcount = 2 Then
picSecond.Picture = imgPicture(i).Picture
picSecond.Tag = i
Else
picFirst.Picture = imgPicture(i).Picture
picFirst.Tag = i
End If
End If
Next i
If clickcount = 2 Then
Call CheckMatch
End If
End Sub
Public Sub CheckMatch()
Dim i As Integer
If picFirst.Tag = picSecond.Tag Then
tmrWin.Enabled = True
clickcount = 0
Else
tmrLose.Enabled = True
clickcount = 0
End If
End Sub
Re: Looping to see if something = something
I think you need another array of default picture names. When you click picture6 and it has image 4 in it, you would want to save pointer(4) to the tag property. The method I posted won't work because you won't be clicking on the same picture twice, so they won't match. If both tags contained pointer(4), they would match.
Post your project and I'll look at it.
1 Attachment(s)
Re: Looping to see if something = something
Re: Looping to see if something = something
I'll look at it when I get back.
Re: Looping to see if something = something
1 Attachment(s)
Re: Looping to see if something = something
I had to make a few changes, but I think you'll like it :)
Re: Looping to see if something = something
thanks david, it works great. :wave: