|
-
Jul 3rd, 2009, 06:24 PM
#1
Thread Starter
Addicted Member
[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
-
Jul 3rd, 2009, 06:30 PM
#2
Fanatic Member
Re: msgbox not displaying correct msg
You have else there, you can have only one msgbox shown.
-
Jul 3rd, 2009, 06:42 PM
#3
Thread Starter
Addicted Member
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
-
Jul 3rd, 2009, 07:31 PM
#4
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
-
Jul 3rd, 2009, 08:18 PM
#5
Thread Starter
Addicted Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|