Results 1 to 5 of 5

Thread: [RESOLVED] msgbox not displaying correct msg

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jun 2005
    Posts
    151

    Resolved [RESOLVED] msgbox not displaying correct msg

    can someone look and tell me why this aint working please

    Code:
    Private Sub ReelSpinTimer_Timer()
    If ReelSpinTimer.Enabled = False Then
        If imgReel1b.Picture = LoadResPicture(110, vbResBitmap) And imgReel2b.Picture = LoadResPicture(110, vbResBitmap) And imgReel3b.Picture = LoadResPicture(110, vbResBitmap) Then
            MsgBox "Win", vbOKOnly, "win"
                Else
            MsgBox "Lose", vbOKOnly, "lose"
    End If
    End If
    
    End Sub
    when my reelspintimer stops all i get is the msgbox "Lose", vbOKOnly, "lose" msg and not the win msg.

    thanks for your help

  2. #2
    Fanatic Member Dungeon Keeper's Avatar
    Join Date
    Mar 2008
    Posts
    590

    Re: msgbox not displaying correct msg

    You have else there, you can have only one msgbox shown.
    No, that wont do!

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jun 2005
    Posts
    151

    Re: msgbox not displaying correct msg

    i see what you mean but when i take out

    Code:
     else 
    MsgBox "Lose", vbOKOnly, "lose"
    i dont get a msgbox at all therefore i dont think my code is correct to have my program determine if i have a win or not, any suggestions

    what i want to do is have 3 images look like they are spinning round like a fruit machine and when my timer stops if the winline has xxx on it i want a msgbox to say win if the win line displays oxo i want a msg box to say lose.

    i have my images in a resource file with x as 110 and o as 109 and bar as 108

  4. #4
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: msgbox not displaying correct msg

    The following IF statement will never return true
    Code:
    If imgReel1b.Picture = LoadResPicture(110, vbResBitmap) And imgReel2b.Picture = LoadResPicture(110, vbResBitmap) And imgReel3b.Picture = LoadResPicture(110, vbResBitmap) Then
    Why? Each time LoadResPicture is called, a copy of the resource is loaded with a new handle. Therefore your pictures loaded into your image controls (their handles) will never equal the handle returned by LoadResPicture.

    You will need to come up with another method of checking the images. Suggestion: When you load an image into your image controls, store the res id in the image control's tag property, example follows:
    Code:
     ' each time you load the image...
    imgReel1b.Picture = LoadResPicture(110, vbResBitmap)
    ' store the id in the tag:
    imgReel1b.Tag = 110
    
    ' now when it comes time to compare, your new IF statement might look like:
    If imgReel1b.Tag = "110" And imgReel2b.Tag = "110" And imgReel3b.Tag = "110" Then
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Jun 2005
    Posts
    151

    Re: msgbox not displaying correct msg

    thankyou so much for your help guys

    lavolpe's reply very interesting thanks for the detail and i tried what you said storing the res id to the imgreel1b.tag and it worked i get the msgbox popup when i get 3 of the same image on each reel. thanks again

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