Just a quick question, how can I play a wave file in a visual basxic program without needing a command button. Say i wanted to play a wave file on a Got_Focus() event, how could I go about doing so?
Printable View
Just a quick question, how can I play a wave file in a visual basxic program without needing a command button. Say i wanted to play a wave file on a Got_Focus() event, how could I go about doing so?
playing wave files' E Z.
if you're not using Windows 2000, do this:
(Multimedia Control ain't work'n with 2000)
steps:
right-click toolbox.
select Microsoft MultiMedia Control 6.0
(or 5.0, if you have VB 5.0)
click OK.
here's de code:
(inside your module that contains the object that is
going to receive focus)
Option Explicit
Private Sub WhatEver_GotFocus()
MMControl1.DeviceType = "WaveAudio"
MMControl1.FileName = "C:\WINNT\MEDIA\TADA.wav"
MMControl1.Command = "open"
MMControl1.Command = "play"
End Sub
There is an alternative. You can use
the Windows Media Player ActiveX control, or you can write
lots of assembly code inside C++ to make your own ActiveX
control that plays media files.
[Edited by jovton on 11-20-2000 at 03:48 AM]
Thanks man, that helped out alot..
hey, Divide_0verride!
saw my signature? i love to help out newbies! and, i am
a newbie myself. but i do have some experience in vb and
c++, and yes, even vc++ programming. some pascal and
delhpi too! man, i'd love to learn some assembly language!
anyway, it was nice help'n ya.
I don't think you actually need a control to play wav files, you can use the PlaySound API.
In a module:
In your code:Code:Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" ( _
ByVal lpszName As String, _
ByVal hModule As Long, _
ByVal dwFlags As Long _
) As Long
Code:PlaySound "C:\WINNT\MEDIA\TADA.wav", 0, 0
thanks alot both of you... it's been a great help.. my project is nearing it's completion date, and it is crunch time.. laters