How to Play Audio Sound in VB6 application programme. Objective of the programme is very simple,we h
How to Play Audio Sound in VB6 application programme.
Objective of the programme is very simple,we have one
text box in a form,where user will put Numerical data on
it and after entering the data the programme will check
the value and give us a voice output.
Step 1.
For this we need recorded *.wav format audio file form zero to nine.
Record the audio using windows built in voice recorder application.
Start–>Programme –> Accessories—>Entertainment –> Sound Recorder
Step 2.
Write a vb function and placed it in a Module.
///——————put yhis function in a module—————-
Public Function Numarical_Sound(txt As String)
””’—————————-play sound———-
l = Len(txt)
If l = 0 Then
Else
Value = Mid(txt, l, l)
End If
If Value = “1” Then
Call sndPlaySound(“C:\sound\one.wav”, 0)
ElseIf Value = “2” Then
Call sndPlaySound(“C:\sound\two.wav”, 0)
ElseIf Value = “3” Then
Call sndPlaySound(“C:\sound\three.wav”, 0)
ElseIf Value = “4” Then
Call sndPlaySound(“C:\sound\four.wav”, 0)
ElseIf Value = “5” Then
Call sndPlaySound(“C:\sound\five.wav”, 0)
ElseIf Value = “6” Then
Call sndPlaySound(“C:\sound\six.wav”, 0)
ElseIf Value = “7” Then
Call sndPlaySound(“C:\sound\seven.wav”, 0)
ElseIf Value = “8” Then
Call sndPlaySound(“C:\sound\eight.wav”, 0)
ElseIf Value = “9” Then
Call sndPlaySound(“C:\sound\nine.wav”, 0)
ElseIf Value = “0” Then
Call sndPlaySound(“C:\sound\zero.wav”, 0)
End If
End Function
//————————————————————-
Step 3.
Put these codes in another module
Public Declare Function sndPlaySound Lib “winmm.dll” Alias
“sndPlaySoundA” (ByVal lpszSoundName As String, ByVal UFlag As Long) As Long
‘sound
Step 4.
Now come to your vb form and write these codes in any event of the text box
|—————————— -x |
| VB FORM |
| |
| ——– |
| TEXT BOX sound |
| ——– ()ON |
| (.)OFF |
| |
| |
| |
————————————–
”’———call sound—————–
If OptionON.Value = True Then
A = Numarical_Sound(txt)
Else
‘do nothing
End If
”’————————————