通用
Private Declare Function PlaySound Lib "winmm. dll" Alias "PlaySoundA"
(ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long)
As Long
按钮
Private Sub Command1_Click()
playwavefile = PlaySound("声音文件名. wav", 0&, lngflags)
End Sub
正确例题
Private Declare Function Beep Lib "kernel32" (ByVal dwFreq As Long,
ByVal dwDuration As Long) As Long
Private Sub Command1_Click()
Dim X(24) As Integer, I As Integer, J As Integer
X(1) = 784: X(2) = 659: X(3) = 523: X(4) = 784
X(5) = 659: X(6) = 523: X(7) = 880: X(8) = 698
X(9) = 587: X(10) = 880: X(11) = 698: X(12) = 587
X(13) = 1568: X(14) = 1318: X(15) = 1046
X(16) = 1568: X(17) = 1318: X(18) = 1046
X(19) = 1760: X(20) = 1396: X(21) = 1174
X(22) = 1760: X(23) = 1396: X(24) = 1174
For I = 1 To 2
For J = 1 To 24
Beep X(J) , 200
Next J
Next I
End Sub