Untuk proyek kita kali ini membutuhkan controll, yaitu :
- 2 text box dengan propertis name text1 dan text2
- 4 command buttons dengan properties namenya standar/default tanpa perubahan.
- 3 label dengan properties name default
- contoh-contoh file sound wav yang diletakan di luar aplikasi
- timer dengan properties name timer1 dan dengan interval 100.
Tuliskan code di bawah ini pada modul
Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" _ (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long Const SND_SYNC = &H0 Const SND_ASYNC = &H1 Const SND_NODEFAULT = &H2 Const SND_LOOP = &H8 Const SND_NOSTOP = &H10 Sub PlayWaveSoundOkExit_Click() soundfile$ = "audio\rain_tag_water.wav" wFlags% = SND_ASYNC Or SND_NODEFAULT HaHa = sndPlaySound(soundfile$, wFlags%) End Sub Sub StopTheSound_Click() StopTheSoundNOW = sndPlaySound(soundfile$, wFlags%) End Sub Sub PlayWaveSoundIntro_Click() soundfile$ = "audio\a_sparrow.wav" wFlags% = SND_ASYNC Or SND_NODEFAULT HaHa = sndPlaySound(soundfile$, wFlags%) End Sub Sub PlayWaveSoundLblTxt_Click() soundfile$ = "audio\e_twigs.wav" wFlags% = SND_ASYNC Or SND_NODEFAULT HaHa = sndPlaySound(soundfile$, wFlags%) End Sub Sub PlayWaveSoundAyam_Click() soundfile$ = "audio\Ayam berkokok.wav" wFlags% = SND_ASYNC Or SND_NODEFAULT HaHa = sndPlaySound(soundfile$, wFlags%) End Sub
Tuliskan code di bawah ini pada Form
Private Sub Command1_Click() PlayWaveSoundOkExit_Click End End Sub Private Sub Command2_Click() PlayWaveSoundAyam_Click End Sub Private Sub Command3_Click() StopTheSoundNOW = sndPlaySound(soundfile$, wFlags%) End Sub Private Sub Command4_Click() PlayWaveSoundOkExit_Click Timer1.Enabled = False Command2.Visible = True Command3.Visible = True Command4.Visible = False Command1.Visible = True End Sub Private Sub Form_Load() PlayWaveSoundIntro_Click MsgBox "Sound Wav Intro telah berbunyi, selanjutnya Sound Wav saat menekan Ok", vbOKOnly, "Info" PlayWaveSoundOkExit_Click End Sub Private Sub Text1_Change() PlayWaveSoundLblTxt_Click End Sub Private Sub Text2_Change() PlayWaveSoundLblTxt_Click End Sub Private Sub Timer1_Timer() If Not Text1.Text = "" And Not Text2.Text = "" Then Command4.Visible = True Else Command4.Visible = False End If If Label3.ForeColor = &HFFFFFF Then Label3.ForeColor = &H80000008 Else Label3.ForeColor = &HFFFFFF End If End Sub
Terimakasih, semoga bermanfaat.
Download Menambah Sound Wav
0 komentar:
Posting Komentar