Saturday, April 3, 2010

VB6 Code - Menjalankan File .wav Menggunakan Visual Basic

Di bawah ini merupakan fungsi VB6 untuk menjalankan file .wav dengan menggunakan Visual Basic 6.0 disertai dengan beberapa argumen yang dibutuhkan.
Option Explicit

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

Public Enum SoundOption
SND_SYNC = &H0
SND_ASYNC = &H1
SND_NODEFAULT = &H2
SND_LOOP = &H8
SND_NOSTOP = &H10
End Enum

Public Sub PlaySound(Filename As String, Optional OpsiSound As SoundOption = SND_ASYNC Or SND_NODEFAULT)
Dim sThewavsound As String, ret As Long
sThewavsound = Filename
ret = sndPlaySound(sThewavsound, OpsiSound)
End Sub
Contoh Penggunaan fungsi menjalankan file .wav menggunakan visual basic 6.0
Private Sub Command1_Click()
PlaySound Text1.Text, SND_ASYNC
End Sub