| | |
adding sound
Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Oct 2005
Posts: 62
Reputation:
Solved Threads: 0
how can i make the program play a sound when my tmer is finished?
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
If txtSec.Text = 0 And txtMin.Text = 0 And txtHour.Text = 0 Then Timer1.Enabled = False <--------need sound to play here until cmd button pressed to stop it. EndIf
First you have to delcare this API
after that
or you could try Beep function, it is make beep sound
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
Private Declare Function sndPlaySound Lib "winmm.dll" Alias _ "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
after that
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
If txtSec.Text = 0 And txtMin.Text = 0 And txtHour.Text = 0 Then Timer1.Enabled = False result = sndPlaySound(location, 1) EndIf
or you could try Beep function, it is make beep sound
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
Private Declare Function sndPlaySound Lib "winmm.dll" Alias _ "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long Private Sub Form_Load() result = sndPlaySound("C:\sound.wav",1) End Sub
this code can only play wav file, it cannot play mp3 file, you have to convert mp3 file to wav file.
•
•
Join Date: Oct 2005
Posts: 62
Reputation:
Solved Threads: 0
so umm, sry 4 being annoying, but if this is my code, were does this piece go?
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
Private Sub SDOpt_Click(Index As Integer) Dim Msg As String Msg = "Spin Dry is" Select Case SDOpt(Index).Index Case 0 Msg = Msg & " On" Case 1 Msg = Msg & " Off" End Select Text7.Text = Msg End Sub Private Sub SSOpt_Click(Index As Integer) Dim Msg As String Msg = "Spin Speed is" Select Case SSOpt(Index).Index Case 0 Msg = Msg & " Fast" Case 1 Msg = Msg & " Medium" Case 2 Msg = Msg & " Slow" End Select Text6.Text = Msg End Sub Private Sub WLOpt_Click(Index As Integer) Dim Msg As String Msg = "Water Level" Select Case WLOpt(Index).Index Case 0 Msg = Msg & " High" Case 1 Msg = Msg & " Medium" Case 2 Msg = Msg & " Low" End Select Text4.Text = Msg End Sub Private Sub WTOpt_Click(Index As Integer) Dim Msg As String Msg = "Water Temp." Select Case WTOpt(Index).Index Case 0 Msg = Msg & " Hot" Case 1 Msg = Msg & " Warm" Case 2 Msg = Msg & " Cold" End Select Text5.Text = Msg End Sub Private Sub Timer1_Timer() If txtSec.Text = 0 And txtMin.Text = 0 And txtHour.Text = 0 Then Timer1.Enabled = False ElseIf txtSec.Text > 0 Then txtSec.Text = txtSec.Text - 1 Else 'if zero txtSec.Text = 59 If txtMin.Text > 0 Then 'update mins txtMin.Text = txtMin.Text - 1 Else 'check if Hour is 0, and if it is, then stop timer, else continue txtMin.Text = 59 If txtHour.Text > 0 Then 'update mins txtHour.Text = txtMin.Text - 1 Else 'check if Hour is 0, and if it is, then stop timer, else continue txtHour.Text = 59 End If End If End If End Sub Private Sub startcmd_Click() If startcmd.Caption = "Start Washing" Then Timer1.Enabled = True startcmd.Caption = "Pause / Stop" ElseIf startcmd.Caption = "Pause / Stop" Then Timer1.Enabled = False startcmd.Caption = "Start Washing" End If End Sub
put this code on the top of your code
and
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
Private Declare Function sndPlaySound Lib "winmm.dll" Alias _ "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
and
If txtSec.Text = 0 And txtMin.Text = 0 And txtHour.Text = 0 Then
Timer1.Enabled = False
result = sndPlaySound("C:\mysound.wav", 1)•
•
Join Date: Jan 2006
Posts: 1
Reputation:
Solved Threads: 0
hi invisal, will u mind helping me to slove this problem? i will thanks u alots. my problem is quite same as i want to play recored sound in wav form in C++ so don't mind helping me?
as wat u have say putting this code on top of rhe whole program rite but i using C++ it come up with the following problem which is under the code that u have post. don't mind take a look on it n see whether u can help me. thanks.
[QUOTE=invisal]put this code on the top of your code
n do i need to declare the result under which variable? like int, float, unsign char...... or just leave it whitout any declaration?
result = sndPlaySound("C:\mysound.wav", 1)
or do u have any other better way for C++?
--------------------Configuration: Vsdemo - Win32 Debug--------------------
Compiling...
VC.cpp
C:\KangyingCong\Web_C++LASTday\C++Vision\VC.cpp(50) : error C2146: syntax error : missing ';' before identifier 'Declare'
C:\KangyingCong\Web_C++LASTday\C++Vision\VC.cpp(50) : error C2501: 'Private' : missing storage-class or type specifiers
C:\KangyingCong\Web_C++LASTday\C++Vision\VC.cpp(50) : fatal error C1004: unexpected end of file found
Error executing cl.exe.
VC.exe - 3 error(s), 0 warning(s)
as wat u have say putting this code on top of rhe whole program rite but i using C++ it come up with the following problem which is under the code that u have post. don't mind take a look on it n see whether u can help me. thanks.
[QUOTE=invisal]put this code on the top of your code
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
Private Declare Function sndPlaySound Lib "winmm.dll" Alias _ "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
n do i need to declare the result under which variable? like int, float, unsign char...... or just leave it whitout any declaration?
result = sndPlaySound("C:\mysound.wav", 1)
or do u have any other better way for C++?
--------------------Configuration: Vsdemo - Win32 Debug--------------------
Compiling...
VC.cpp
C:\KangyingCong\Web_C++LASTday\C++Vision\VC.cpp(50) : error C2146: syntax error : missing ';' before identifier 'Declare'
C:\KangyingCong\Web_C++LASTday\C++Vision\VC.cpp(50) : error C2501: 'Private' : missing storage-class or type specifiers
C:\KangyingCong\Web_C++LASTday\C++Vision\VC.cpp(50) : fatal error C1004: unexpected end of file found
Error executing cl.exe.
VC.exe - 3 error(s), 0 warning(s)
![]() |
Similar Threads
- Reformatted, Reinstalled, no Sound (Windows NT / 2000 / XP)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: idea on the given module in IVRS using visualbasic
- Next Thread: Finding duplicated names in a Sequential/Random File
Views: 4539 | Replies: 10
| Thread Tools | Search this Thread |
Tag cloud for Visual Basic 4 / 5 / 6
* 6 429 2007 access activex add age append application basic beginner birth bmp c++ calculator cd cells.find click client code college column connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report retrieve save search sendbyte sites sort sql sql2008 sqlserver struct subroutine table tags textbox time timer urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window





