vb.net - Play a sound in vb -
okay, have perfected game called lucky 7 using visual studio 2010. want play sound when have won game (got 7 on 1 of 3 slots). here code:
private sub button1_click(sender system.object, e system.eventargs) handles button1.click = 0 2 slots(i) = rand.next(10) next label1.text = (slots(0).tostring) label2.text = (slots(1).tostring) label3.text = (slots(2).tostring) if slots(0) = 7 or slots(1) = 7 or slots(2) = 7 score = score + 100 'rem 10 points each win label4.text = (score.tostring) picturebox1.visible = true 'rem if have picturebox playsound "c:\windows\media\tada.wav", else picturebox1.visible = false end if if score = 500 msgbox("you scored 500 points!", vbinformation) end if end sub
thing is, error on 'playsound' statement , want play sound when player wins game!
i tried create reset button, sets score , 3 slots 0, when click it, nothing happens. here code reset button:
private sub button2_click(sender system.object, e system.eventargs) handles button2.click score = 0 picturebox1.visible = false end sub
try using my.computer.audio.play
have walked through code make sure nothing happening on button click event? clicking far left of line "score = 0" set break-point. pause code when run it. can hover on variable score, , show it's value. pressing [f8] execute it, , can hover on , see it's changed.
Comments
Post a Comment