Results 1 to 35 of 35

Thread: Some help pls

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Oct 2018
    Location
    Athens
    Posts
    129

    Some help pls

    Hi ,
    l have an array of say 30 picture boxes (pic(1),pic(2) etc) each having a different image and not in sequence
    l have another array of 30 empty picture boxes (mic(1),mic(2) etc) in sequence
    This is no a jigsaw puzzle .
    The user can move with the clipboard method images to the empty boxes but they have to be placed in a proper
    empty box in order to meet the criteria of the game.
    So far l have no problem but l what l would like is to have some kind of notification when the user completes
    placing all the images , say so % , or if completed correctly a Msgbox with congrats . That kind of thing .

    l'll appreciate feedback

  2. #2
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    13,817

    Re: Some help pls

    You could just use a numeric variable. Set it to 0 at start and increment each time an image goes to the correct place then check the value of that variable to see how much progress has been made. Should be simple.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Oct 2018
    Location
    Athens
    Posts
    129

    Re: Some help pls

    l have tried that already . It doesn't work like this. The user might place a image on the wrong place , and then he will try another and then another .
    Which means that every time the image must return to it's original place . Forget the percentage It would be ideal when placing the last image with
    a button to check his/her success

  4. #4
    Frenzied Member
    Join Date
    Dec 2014
    Posts
    1,590

    Re: Some help pls

    u need to create a function, lets call it "analyze"
    this will loop at each picturebox and check if theres the right pic/box or not.
    u call this function each time the user places a pic into any of the boxes.
    in the same time, when a user is placing a pic into a box, u check "is pic correct box" if yes u add a "1" to the .tag property if not u add "0", that way u can check the tag in the "analyze" function.

  5. #5
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    13,817

    Re: Some help pls

    Quote Originally Posted by vbgeobas View Post
    l have tried that already . It doesn't work like this. The user might place a image on the wrong place , and then he will try another and then another .
    Which means that every time the image must return to it's original place .
    I don't see where that would pose a problem with what I suggested. You would only increment the variable when they place the image in the correct location. Now if you are saying they are allowed to move the image from the correct location once it has been put there then that is a different case altogether and would require a different approach.

  6. #6
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    8,071

    Re: Some help pls

    baka has a solution suggested. Should work just fine if you do what he posted.
    Sam I am (as well as Confused at times).

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Oct 2018
    Location
    Athens
    Posts
    129

    Re: Some help pls

    @SamOscarBrown .Sorry for late reply l was away from a couple of days.
    What @baka has suggested would be fine if the user was to place a image once and left it there , but this is a case where he would take
    it back and try another until in his mind the combination of placing the images meets the criteria .
    l've used a numeric variable +1 if placed in the right spot and -1 if the user takes it back or nil if when in the wrong spot but it does not
    work because it all gets a mess if the user when taking back the image doesn't place it in it's right place .
    If l may say , this project was working fine until l had the idea to have some kind of appreciation for the user if he/she solves it .

  8. #8
    Frenzied Member
    Join Date
    Dec 2014
    Posts
    1,590

    Re: Some help pls

    that is why u need the "analyze" function.
    each time the user is placing an image to a box, u call the analyzer"

    what the analyzer do?
    if will ckeck all boxes and check all images if the right image is in the right box

    example:

    for i = 1 to 10
    if pic(i).tag="1" then found = found + 1
    next i

    if found = 10 then all pics are in the right boxes

    and

    for the .tag u need to check, when the user is "placing" a pic, you do:
    if pic(i) is in the right box you pic(i).tag = "1" otherwise you pic(i).tag = "0"

    and of course after you do that, u call the analyzer as well.

  9. #9

    Thread Starter
    Addicted Member
    Join Date
    Oct 2018
    Location
    Athens
    Posts
    129

    Re: Some help pls

    That would be OK if the images to be placed were in the same sequence with the boxes . In that case the user wold know that
    1 goes to 1, 2 goes to 2 etc .So where is the puzzle ?

  10. #10
    Frenzied Member
    Join Date
    Dec 2014
    Posts
    1,590

    Re: Some help pls

    that is your job as the programmer to know that.
    if u randomize or just have a specific position, that u need to program.
    so, if pic(1) should be placed in box(7), u need to program that.
    that u could do in the tag system as well, like

    box(1).tag = 5
    box(2).tag = 3 etc
    that means, pic(5) need to be placed in box(1)

    u can, when u place a pic(i) into a box, you can still use the .tag so pic(i).tag = box.index
    so, when u place any pics into the box, you call the "analyzer"
    the analyzer will check all boxes so,

    for i = 1 to 10 (assume we have 10 boxes)
    if pic(box(i).tag).tag = i then found = found + 1
    next i

  11. #11

    Thread Starter
    Addicted Member
    Join Date
    Oct 2018
    Location
    Athens
    Posts
    129

    Re: Some help pls

    Thank you @baka .
    l'll work on it .
    Have to go now . l'll let you know tomorrow how it geoes

  12. #12

    Thread Starter
    Addicted Member
    Join Date
    Oct 2018
    Location
    Athens
    Posts
    129

    Re: Some help pls

    Hi , l am back

    Attachment 182625

    Here is y Code but it does not work

    Dim i As Integer
    Dim Coeff As Integer
    Dim Found As Integer

    Private Sub Form_Load()
    Found = 0
    Box(1).Tag = 3
    Box(2).Tag = 5
    Box(3).Tag = 1
    Box(4).Tag = 2
    Box(5).Tag = 4
    '
    Pic(1).Tag = 3
    Pic(2).Tag = 5
    Pic(3).Tag = 1
    Pic(4).Tag = 2
    Pic(5).Tag = 4
    End Sub

    Private Sub Pic_Click(Index As Integer)
    Coeff = Index
    End Sub

    Private Sub Box_Click(Index As Integer)
    On Error Resume Next
    If Box(Index).Picture.Handle = 0 Then
    Box(Index).Picture = Pic(Coeff).Picture
    'Pic(1).Tag = Box.Index ' this doesn't work Error
    Else
    Box(Index).Picture = Box(Index).Picture
    Set Box(Index) = Nothing
    End If
    Text1 = Box(Index).Tag
    Call Analyser
    End Sub

    Private Sub Analyser()
    For i = 1 To 5
    'If Pic(i).Tag = Box(i).Tag Then Found = Found + 1
    If Pic(Box(i).Tag).Tag = i Then Found = Found + 1
    Next
    Text1 = Found
    End Sub
    Last edited by vbgeobas; Oct 15th, 2021 at 11:43 AM.

  13. #13
    Frenzied Member
    Join Date
    Dec 2014
    Posts
    1,590

    Re: Some help pls

    can't download the attachment, need to upload so it can be downloaded.

  14. #14

    Thread Starter
    Addicted Member
    Join Date
    Oct 2018
    Location
    Athens
    Posts
    129

    Re: Some help pls

    HereName:  SCREEN.jpg
Views: 80
Size:  80.4 KB

  15. #15
    Frenzied Member
    Join Date
    Dec 2014
    Posts
    1,590

    Re: Some help pls

    so u click on a picture, to select it, and click on a box to move it there?
    u can place same pic in multiple boxes?
    and when u click on a box, it will change color of the selected pic?
    Last edited by baka; Oct 15th, 2021 at 01:20 PM.

  16. #16
    Frenzied Member
    Join Date
    Dec 2014
    Posts
    1,590

    Re: Some help pls

    Dim i As Integer
    Dim Coeff As Integer
    Dim Found As Integer
    Dim solution(1 to 5) as integer

    Private Sub Form_Load()
    solution(1) = 3
    solution(2) = 5
    solution(3) = 1
    solution(4) = 2
    solution(5) = 4
    End Sub

    Private Sub Pic_Click(Index As Integer)
    Coeff = Index
    End Sub

    Private Sub Box_Click(Index As Integer)
    If Box(Index).Picture.Handle = 0 Then
    Box(Index).Picture = Pic(Coeff).Picture
    Box(Index).Tag = Coeff
    End if
    found = 0
    For i = 1 To 5
    if val(box(i).Tag) = solution(i) then Found = Found + 1
    Next i
    Text1.Text = Found
    End Sub

    (I wrote this here, not in IDE, so it could contain errors)

  17. #17

    Thread Starter
    Addicted Member
    Join Date
    Oct 2018
    Location
    Athens
    Posts
    129

    Re: Some help pls

    Quote Originally Posted by baka View Post
    so u click on a picture, to select it, and click on a box to move it there?
    u can place same pic in multiple boxes?
    and when u click on a box, it will change color of the selected pic?
    1. Yes , clck on a box to move it there . With my code if you don't like the place on the box , you click on it and by clicking another box it moves there.
    2. No , one picture per box
    3. Yes as per 2

    Your code does not work , the values in text1 box , are far from what they should be , and you cannot change box of the mage

  18. #18
    Frenzied Member
    Join Date
    Dec 2014
    Posts
    1,590

    Re: Some help pls

    well. the solution seems to be 1,2,3,4,5 not 3,5,1,2,4 as u wrote.
    so change the 5 solution to that and it will work.

  19. #19

    Thread Starter
    Addicted Member
    Join Date
    Oct 2018
    Location
    Athens
    Posts
    129

    Re: Some help pls

    The counting of right placings works fine.
    l have added two lines of code in order to erase the pic from the box by clicking on it in case you want to move it to another box (which is common).

    Private Sub Box_Click(Index As Integer)
    If Box(Index).Picture.Handle = 0 Then
    Box(Index).Picture = Pic(Coeff).Picture
    Box(Index).Tag = Coeff
    Else
    Set Box(Index).Picture = Nothing
    End If
    Found = 0
    For i = 1 To 5
    If Val(Box(i).Tag) = solution(i) Then Found = Found + 1
    Next i
    Text1.Text = Found
    End Sub

    Thank you very much for you assistance and time

  20. #20

    Thread Starter
    Addicted Member
    Join Date
    Oct 2018
    Location
    Athens
    Posts
    129

    Re: Some help pls

    @baka
    It seems l was very enthousiastic or tired last night and did not notice that we are back to square one , that is the counting
    which was the problem from the beginning . l'll explain .
    The user moves the image in a box and if it's not the right box Found is nothing . Then he moves it to the right box and he
    gets Found=1 , so far OK , but then he changes his mind and places it in a wrong box and leaves it there before he starts
    moving another pic .So the first picture is in a wrong box and the Found 1 , remains .
    The original idea was "to have some kind of notification when the user completes placing all the images " and NOT the user
    to know if he places the pic to the right box . The user does not see the results in Text1 .
    l'll keep working on it trying to find a real solution ,

    Thank again

  21. #21
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    8,071

    Re: Some help pls

    well, if 'he changes his mind', then he would be moving it out of the box, correct? And this would leave the box blank. Simply detriment 'Found' by 1 when he does this.
    Sam I am (as well as Confused at times).

  22. #22

    Thread Starter
    Addicted Member
    Join Date
    Oct 2018
    Location
    Athens
    Posts
    129

    Re: Some help pls

    It will not work , because if he/she moves the picture to a wrong box and then to another wrong box , if he/she moves it to the right box ,
    he/she will end up with -1.
    In actual fact the user is not to know what is the result of his placements until he places the last pic . So the check of the success is to
    be after the 5 bxes are filled .

  23. #23
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    8,071

    Re: Some help pls

    How about something like this (for an example)?

    Note: I hinted that you need to randomize the correct solution, but did not include that code.
    I also used a STRING for the solution, but a better way may be to use an array. You can easily reset that array using the Random function for each 'game'.

    Sam

    (I just threw this together in about 30 minutes, so much can be coded better...)
    Attached Files Attached Files
    Sam I am (as well as Confused at times).

  24. #24

    Thread Starter
    Addicted Member
    Join Date
    Oct 2018
    Location
    Athens
    Posts
    129

    Re: Some help pls

    Sam , with all due respect , what that has to do with the scenario of my project ?
    FYI , eventually l've made it . If you're interested l could post it for you

    Cheers
    George

  25. #25
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    13,817

    Re: Some help pls

    It seems pretty simple really. I initially suggested the counter because I did not know what you were doing but a simple validate procedure that you call each time they move a picture should work just fine. In other words create a little function that checks all the boxes to see if they have the right image in them and have it return the number of correct placements. Call this function every time they move a picture and you will always be able to tell how many are in the correct positions.

  26. #26

    Thread Starter
    Addicted Member
    Join Date
    Oct 2018
    Location
    Athens
    Posts
    129

    Re: Some help pls

    @DataMiser . This is what l have done . l was doing that the hard way using the index of the pictures comparison.
    a simple "if pict(i).picture=box(i).picture" has done the job either the pic is in the right place or moved to a wrong place .

  27. #27
    Frenzied Member
    Join Date
    Dec 2014
    Posts
    1,590

    Re: Some help pls

    look here

    If Box(Index).Picture.Handle = 0 Then
    Box(Index).Picture = Pic(Coeff).Picture
    Box(Index).Tag = Coeff
    Else
    Set Box(Index).Picture = Nothing
    Box(Index).Tag = vbNullString (or "" if u prefer that)
    End If

    if u make the picture to nothing, u should also empty the tag.

  28. #28
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    8,071

    Re: Some help pls

    my example has EVERYTHING to do with your scenario...when a use clicks on a picture1, and then clicks on one of the picture2's, it puts that picture from 1 to 2. When all are completed, it uses a simple verification that all images in the picture2's are in the right place...if not, clear it all and restart...pretty darn simple.

    what YOU are missing is what baka keeps trying to tell you...use a verification routine to see if the pictures are in the right place or not (like I did, for example).

    I would LOVE to see your project...please zip and post...maybe I'll learn something!
    Sam I am (as well as Confused at times).

  29. #29

    Thread Starter
    Addicted Member
    Join Date
    Oct 2018
    Location
    Athens
    Posts
    129

    Re: Some help pls

    @baka and @SamOscarBrown
    You both take it for granted that the user will place a pic in a box and leave it there . It doesn't work like that because he might , and will try
    different boxes before he/she decides ,in his mind, that he has the right box . If you don't make the pic to nothing , if he changes box all the
    boxes he tries will be having the same pic .
    It's all Columbus Egg and it's in the last sentence of @DataMiser post 25
    "Call this function every time they move a picture and you will always be able to tell how many are in the correct positions."
    So here is the final code that works .

    Private Sub Pic_Click(Index As Integer)
    Coeff = Index
    End Sub

    Private Sub Box_Click(Index As Integer)
    If Box(Index).Picture.Handle = 0 Then
    Box(Index).Picture = Pic(Coeff).Picture
    CheckResult
    Else
    Set Box(Index).Picture = Nothing
    CheckResult
    End If
    End Sub

    Private Sub CheckResult()
    Found = 0
    For i = 1 To 5
    If Box(i).Picture = Pic(i).Picture Then Found = Found + 1
    Next i
    Text1.Text = Found
    if val(text1.text)=5 then msgbox"Bla bla bla ..."
    End Sub
    ....
    PS : @SamOscarBrown ... You don't have to be sarcastic . Some of us are not experts therefore we are asking for help .

    Have a nice day all
    Last edited by vbgeobas; Oct 17th, 2021 at 03:17 AM.

  30. #30
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    8,071

    Re: Some help pls

    was not being sarcastic...i wanted to know how you did this...going to post your project?
    Sam I am (as well as Confused at times).

  31. #31
    Frenzied Member
    Join Date
    Dec 2014
    Posts
    1,590

    Re: Some help pls

    did u add Box(Index).Tag = vbNullString before the reply. do that first.
    and place Box(Index).Tag = Coeff back again.
    if u keep changing all the time of course it will not work.
    Last edited by baka; Oct 17th, 2021 at 07:48 AM.

  32. #32

    Thread Starter
    Addicted Member
    Join Date
    Oct 2018
    Location
    Athens
    Posts
    129

    Re: Some help pls

    Quote Originally Posted by baka View Post
    did u add Box(Index).Tag = vbNullString before the reply. do that first.
    and place Box(Index).Tag = Coeff back again.
    if u keep changing all the time of course it will not work.
    l don't know why you insist . Of course there is the possibility of changing all the time .
    The code in my last post works just fine , and not for 5 but 25 pics and boxes

  33. #33

    Thread Starter
    Addicted Member
    Join Date
    Oct 2018
    Location
    Athens
    Posts
    129

    Re: Some help pls

    Quote Originally Posted by SamOscarBrown View Post
    was not being sarcastic...i wanted to know how you did this...going to post your project?
    Your post smells sarcasm a mile away to me anyway . OK forget it .
    The code in my last post is the whole project and works just fine . Just add 5 Pics() and 5 Box() and a couple of Dims .

  34. #34
    Frenzied Member
    Join Date
    Dec 2014
    Posts
    1,590

    Re: Some help pls

    if u can do it yourself why do u ask for help? Im starting to think u are just messing with us. I dont have time helping someone that don't want help.

  35. #35

    Thread Starter
    Addicted Member
    Join Date
    Oct 2018
    Location
    Athens
    Posts
    129

    Re: Some help pls

    Quote Originally Posted by baka View Post
    if u can do it yourself why do u ask for help? Im starting to think u are just messing with us. I dont have time helping someone that don't want help.
    That was very unfair .
    l asked for help , using everyone's suggestions and by "try and error" l ended up with what l wanted .
    If some of your suggestions didn't work , as you have mentioned QUOTE (if u keep changing all the time of course it will not work)UNQUOTE , it's not m fault .

    Thanks anyway

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