I am writing a music software in visual basic as my final year project and am having problems with displaying a piano and loading sounds into each of the notes.Can someone please!!!! come to my aid. Any help given will be appreciated

9 Years
Discussion Span
Last Post by binoj_daniel

if ur intension is only to play the sound files, use windows media player control or windows multimedia control or in advance u can also use the "mcisendstring" api libraries.


what do you use in your form??

if a command button, try loading the sound clip when the command button is click
the do something like


make the Mpeg(or media player) set to visibled = false


Here is how you can play wav files.
1. Add a command button and a common dialog box. Copy and paste the sndPlaySound Declare statement from the API Viewer into your application. Also copy the SND_SYNC and SND_ASYNC constants.

Private Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
Private Const SND_ASYNC = &H1
Private Const SND_SYNC = &H0

2. Add this code to the Command1_Click procedure:

Private Sub Command1_Click()
Dim RtnVal As Integer
'Get name of .wav file to play
CommonDialog1.Filter = "Sound Files|*.wav"
RtnVal = sndPlaySound(CommonDialog1.filename, SND_SYNC)
End Sub

This article has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.