背景音乐


【实例说明】
    在游戏中的背景音乐。

【编程思路】
    VB程序中背景音乐的制作就是调用API函数。

【设计步骤】
    1.新建一个标准工程,创建一个新窗体和一个标准模块,默认名分别为Form1和Module1。
    2.在Form1上添加一个CommandButton控件

    3.源程序  [素材源程序下载]


'在模块中添加以下程序:
Option Explicit
'API函数的运用,制作背景音乐
Declare Function sndPlaySound Lib "WINMM.DLL" Alias "sndPlaySoundA" _
        (ByVal lpszSoundName As String, _
        ByVal uFlags As Long) As Long

'在窗体中添加以下程序:
Option Explicit
Public sound As Long

Private Sub Command1_Click()
        sound = sndPlaySound(App.Path + "\sound\sound.wav", &H1)
End Sub