Today we are going to play wav file in vb.net and spell the number using audio files. using winmm.dll, about winmm.dll, it is a module for the Windows Multimedia API, which contains low-level audio and joystick functions and we start to create the application follow the instructions below
Create a Windows Application
- Start Microsoft Visual Studio .NET.
- On the File menu, point to New, and then click Project.
- And Project Types, click Visual Basic Projects.
- Under Templates, click Windows Application.
- Create your project name, type Project1, and then click OK
- Design your form just like the picture below
create module with right clict in the project choose add and add new modul create modul name, type bassSound then we’re going to put this in our code:
we play sound using SND_NOSTOP flags this function will immediately return False without playing the requested sound.
Code:
Specifies options for playing the sound using one or more of the following flags
Code:
In the main form we choose the button1, we're using handle click events or double click button1,to call
function module "say"
Code:
And we turn to button2 same as the button1,we're using handle click events or double click, to call function moudle "sndPlaySound", we call the name to play the sound
Code:
plus button and less button put this in our coude
Code:
wav files sourcecode
Option Strict Off
Option Explicit On
Module bassSound
Public Const SND_NOSTOP As Integer = &H10
Public Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Integer) As Integer
End Module
Specifies options for playing the sound using one or more of the following flags
SND_SYNC: The sound is played synchronously and the function does not return until the sound ends
SND_ASYNC: The sound is played asynchronously and the function returns immediately after beginning the sound.
SND_NODEFAULT: If the sound cannot be found, the function returns silently without playing the default sound.
SND_LOOP: The sound will continue to play repeatedly until ' sndPlaySound is called again with the lpszSoundName$ parameter set to null, You must also specify the SND_ASYNC flag to loop sounds.
create module type with spell and put the code below
create module type with spell and put the code below
Option Strict Off
Option Explicit On
Module spell
Public Function say(ByRef Value As Integer) As String
Select Case Value
Case 0 : say = " zero"
Case 1 : say = " one"
Case 2 : say = " two"
Case 3 : say = " three"
Case 4 : say = " four"
Case 5 : say = " five"
Case 6 : say = " six"
Case 7 : say = " seven"
Case 8 : say = " eight"
Case 9 : say = " nine"
Case 10 : say = " ten"
Case 11 : say = " eleven"
Case 12 : say = " twelve"
Case 13 : say = " thirteen"
Case 14 To 19 : say = say(Value Mod 10) & " teen"
'.....
End Select
End Function
End Module
In the main form we choose the button1, we're using handle click events or double click button1,to call
function module "say"
Code:
TextBox2.Text = Trim(say(CInt(TextBox1.Text)))
And we turn to button2 same as the button1,we're using handle click events or double click, to call function moudle "sndPlaySound", we call the name to play the sound
Code:
Dim i As Object
Dim path(1) As String
Dim arr() As String
arr = Split(TextBox2.Text, " ")
For i = LBound(arr) To UBound(arr)
Call sndPlaySound(path(1) + "Sounds\" & arr(i) + ".wav", SND_NOSTOP)
Next
plus button and less button put this in our coude
Code:
TextBox1.Text = CStr(Val(TextBox1.Text) + 1)
TextBox1.Text = CStr(Val(TextBox1.Text) - 1)
wav files sourcecode
Thanks for the video tips how to create a Windows Application. It's so easy to do, thanks! I managed to do that! Great! pip in here essay help
ReplyDeleteI am glad to have got the info!