Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

on beeps and tones

Status
Not open for further replies.

torturedmind

Programmer
Jan 31, 2002
1,052
PH
am new to VB and am writing an app with 3 dsitinctive sound outputs using only the pc speaker. those 3 distinct sounds are actually 3 separate projects and naturally, compiled into 3 different EXE's. this way, i find that it's much easier for me to re-compile anytime i wanna change the tones of each output. problem is, after running each EXE and i wanna re-compile and update any of them, Windows would not allow me cuz it says that the EXE is still running. here is one of the codes:

Public Declare Function Beep Lib "kernel32" (ByVal dwFreq As Long, ByVal dwDuration As Long) As Long

Sub Main()
For h = 1 To 2
For i = 500 To 1000 Step 20
Beep i, 1
Next i
Next h
End Sub


i know it's kinda simple but i think am missing something. any help will be very much appreciated... :)

torturedmind [trooper]
 
Torturedmind ..
Press Ctrl+Alt+Del ... that will bring up Task manager.. see if your App is listed, if so,end the Task.
My question is why is not closing properly? Do you have other objects references and still running? Did you set all object references = nothing?
Also, have you considered some other methods of doing this without having to recompile an EXE each time you want to change something like a sound? There are better ways.
 
the app was not in the list when pressing Ctl+Alt+Del and no, there were no other object references either. am running the EXE directly by dbl-clicking the EXE file. then after making the speaker beep, the program shd stop but i guess it didn't cuz Windows says it's still running when i update it.

also, i need to do it this way cuz if in the future, i need to change the beep tones, i can do it easily without recompiling the calling app which is by the way, up n running. (err... am having difficulty explaining the reason.) anyways, any more suggestions will be highly appreciated.

torturedmind [trooper]
 
Hmmm, seems that there might be a clue in this phrase:

"without recompiling the calling app which is by the way, up n running."

Sounds as if the "calling app" is still holding a reference to your sound-generating exe. In the calling app, after running the sound-gen exe, try explicitly de-referencing it. Let's say the main form (even if not visible) of the sound-gen exe is frmSoundGen. Use this:

Unload frmSoundGen
Set frmSoundGen = Nothing

That will unload the form and release its object reference.

BTW, there really are much easier ways to accomplish this. For example, you could store the tone frequency and duration values in a simple .ini file. To change the sound, just edit the .ini in any text editor. No recompile, no need even for the VB IDE.

Cheers,
Scott
 
When you look in the Task List (from Ctrl-Alt-Del) to look for your app, it could appear in Processes, not just in Applications. Look for it there. You will probably find it--indicating that it is still running. You might even find multiple copies of it running. BlackburnKL
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top