Results 1 to 15 of 15

Thread: Looping to see if something = something(resolved)

  1. #1

    Thread Starter
    Fanatic Member paralinx's Avatar
    Join Date
    Jun 2005
    Location
    Michigan
    Posts
    987

    Resolved 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:
    1. Dim i As Integer
    2.     clickcount = clickcount + 1
    3.     lblCover(Index).Visible = False
    4.     For i = 0 To 15
    5.         If lblCover(i).Visible = False Then
    6.             If clickcount = 2 Then
    7.                 picSecond.Picture = imgPicture(i).Picture
    8.             Else
    9.                 picFirst.Picture = imgPicture(i).Picture
    10.             End If
    11.         End If
    12.     Next i
    13.    
    14.     Call CheckMatch
    Last edited by paralinx; Oct 1st, 2005 at 08:35 PM.

  2. #2
    Banned randem's Avatar
    Join Date
    Oct 2002
    Location
    Maui, Hawaii
    Posts
    11,385

    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.

  3. #3
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    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.

  4. #4
    Fanatic Member ZeBula8's Avatar
    Join Date
    Oct 2002
    Posts
    548

    Re: Looping to see if something = something

    VB Code:
    1. Dim i As Integer
    2. Static clickcount As Integer
    3.  
    4. clickcount = clickcount + 1
    5. lblCover(Index).Visible = False
    6. For i = 0 To 15
    7.     If lblCover(i).Visible = False Then
    8.         If clickcount = 2 Then
    9.             picSecond.Picture = imgPicture(i).Picture
    10.             clickcount = 0  ' reset
    11.         Else
    12.             picFirst.Picture = imgPicture(i).Picture
    13.         End If
    14.     End If
    15. Next i
    16.  
    17. Call CheckMatch

  5. #5

    Thread Starter
    Fanatic Member paralinx's Avatar
    Join Date
    Jun 2005
    Location
    Michigan
    Posts
    987

    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"

  6. #6
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Looping to see if something = something

    Heres what I meant.

    VB Code:
    1. Dim i As Integer
    2. Static clickcount As Integer
    3.  
    4. clickcount = clickcount + 1
    5. lblCover(Index).Visible = False
    6. For i = 0 To 15
    7.     If lblCover(i).Visible = False Then
    8.         If clickcount = 2 Then
    9.             picSecond.Picture = imgPicture(i).Picture
    10.             picSecond.tag = i
    11.             clickcount = 0  ' reset
    12.         Else
    13.             picFirst.Picture = imgPicture(i).Picture
    14.             picFirst.tag = i
    15.         End If
    16.     End If
    17. Next i
    18.  
    19. Call CheckMatch
    20. '  if picFirst.tag = picSecond.tag  then pictures are the same

  7. #7

    Thread Starter
    Fanatic Member paralinx's Avatar
    Join Date
    Jun 2005
    Location
    Michigan
    Posts
    987

    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?

  8. #8
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Looping to see if something = something

    See post #6. Use the picture index as the tag.

  9. #9

    Thread Starter
    Fanatic Member paralinx's Avatar
    Join Date
    Jun 2005
    Location
    Michigan
    Posts
    987

    Re: Looping to see if something = something

    I'm trying to use this, but it is not working here is my code
    VB Code:
    1. Private Sub lblCover_Click(Index As Integer)
    2.    
    3.     Dim i As Integer
    4.    
    5.     clickcount = clickcount + 1
    6.     lblCover(Index).Visible = False
    7.     For i = 0 To 15
    8.         If lblCover(i).Visible = False Then
    9.             If clickcount = 2 Then
    10.                 picSecond.Picture = imgPicture(i).Picture
    11.                 picSecond.Tag = i
    12.             Else
    13.                 picFirst.Picture = imgPicture(i).Picture
    14.                 picFirst.Tag = i
    15.             End If
    16.         End If
    17.     Next i
    18.     If clickcount = 2 Then
    19.         Call CheckMatch
    20.     End If
    21. End Sub
    22.  
    23. Public Sub CheckMatch()
    24.  
    25.     Dim i As Integer
    26.    
    27.     If picFirst.Tag = picSecond.Tag Then
    28.         tmrWin.Enabled = True
    29.         clickcount = 0
    30.     Else
    31.         tmrLose.Enabled = True
    32.         clickcount = 0
    33.     End If
    34.  
    35. End Sub

  10. #10
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    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.

  11. #11

    Thread Starter
    Fanatic Member paralinx's Avatar
    Join Date
    Jun 2005
    Location
    Michigan
    Posts
    987

    Re: Looping to see if something = something

    Here you go
    Attached Files Attached Files

  12. #12
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Looping to see if something = something

    I'll look at it when I get back.

  13. #13

    Thread Starter
    Fanatic Member paralinx's Avatar
    Join Date
    Jun 2005
    Location
    Michigan
    Posts
    987

    Re: Looping to see if something = something

    Take your time

  14. #14
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Looping to see if something = something

    I had to make a few changes, but I think you'll like it
    Attached Files Attached Files

  15. #15

    Thread Starter
    Fanatic Member paralinx's Avatar
    Join Date
    Jun 2005
    Location
    Michigan
    Posts
    987

    Re: Looping to see if something = something

    thanks david, it works great.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width