![]() |
How to get back the control
Hi,
I have a user form with command buttons cmdPlay and cmdExit. cmdPlay_Click has the following code: Private Sub cmdPlay_Click() sndPlaySound32 "C:Welcom98.wav", 0 End Sub This wave file plays for 30 seconds. cmdExit_Click has the following code: Private Sub cmdExit_Click() End End Sub After clicking cmdPlay, if I am clicking cmdExit then the program is not ending immediately. It is waiting for the wave file to finish playing for 30 seconds. Is it possible that when cmdExit is clicked, within 30 seconds, then the program should end immediately rather than waiting for the whole 30 seconds. Thanks & Regards, Prasad Vanka |
How to get back the control
Prasad Vanka
Not really sure, but did you set the command buttons take focus o click to false? HTH Charle -- Message posted from http://www.ExcelForum.com |
How to get back the control
Hi Charles,
I haven't set the command buttons take focus on click to false. regards, Prasad Vanka *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it! |
How to get back the control
Hi Prasad,
Firstly, you need to play the sound asynchronously, otherwise no code will be able to run until the sound is finished playing. Secondly, if you call sndPlaySound using vbNullString instead of a wav file, it will terminate any other sound that happens to be playing. And last but not least, there's a zillion vb'ers who'll tell you that using End is asking for trouble. Far safer to unload your userform. See an example below. Regards, Vic Eldridge Private Const SND_ASYNC = &H1 Private Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" _ (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long Private Sub cmdPlay_Click() sndPlaySound "C:\WINNT\Media\Windows Logon Sound.WAV", SND_ASYNC End Sub Private Sub cmdExit_Click() sndPlaySound vbNullString, 0 Unload Me End Sub (Prasad Vanka) wrote in message om... Hi, I have a user form with command buttons cmdPlay and cmdExit. cmdPlay_Click has the following code: Private Sub cmdPlay_Click() sndPlaySound32 "C:Welcom98.wav", 0 End Sub This wave file plays for 30 seconds. cmdExit_Click has the following code: Private Sub cmdExit_Click() End End Sub After clicking cmdPlay, if I am clicking cmdExit then the program is not ending immediately. It is waiting for the wave file to finish playing for 30 seconds. Is it possible that when cmdExit is clicked, within 30 seconds, then the program should end immediately rather than waiting for the whole 30 seconds. Thanks & Regards, Prasad Vanka |
All times are GMT +1. The time now is 07:48 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com