Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Playing a wav File

Posted on 1999-01-05
4
Medium Priority
?
278 Views
Last Modified: 2011-04-14
This is probably an easy question... How do I open and play a wav file NOT using the media player looking thing.  I simply want the user to click on a command button and a specific wav file will play.  The following code is fine except it uses that lame looking media control thing

Private Sub Form_Load()
   MMControl1.Notify = False
   MMControl1.Wait = True
   MMControl1.Shareable = False
   MMControl1.DeviceType = "WaveAudio"
   MMControl1.FileName = "C:\WINDOWS\MMDATA\GONG.WAV"
   ' Open the MCI WaveAudio device.
   MMControl1.Command = "Open"
End Sub

Private Sub Form_Unload(Cancel As Integer)
   MMControl1.Command = "Close"
End Sub


0
Comment
Question by:cyber_bandit
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 1

Author Comment

by:cyber_bandit
ID: 1454093
Edited text of question
0
 

Accepted Solution

by:
millej earned 60 total points
ID: 1454094
Declare Function sndplaysound% Lib "mmsystem" (ByVal filename$, ByVal snd_async%)

Public Sub PlaySnd()
   Dim tmp%

   tmp% = sndplaysound("C:\MySound.WAV", 1)
End Sub

0
 
LVL 1

Author Comment

by:cyber_bandit
ID: 1454095
It is telling me mmsystem not found error 48 I think it was.... looks like we are on the right track though... any more ideas?
0
 
LVL 1

Author Comment

by:cyber_bandit
ID: 1454096
Public Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long


This is the one (API Function) which was pointed out to me in VB6
0

Featured Post

Enroll in September's Course of the Month

This month’s featured course covers 16 hours of training in installation, management, and deployment of VMware vSphere virtualization environments. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question