建议你用sndPlaySound这个API函数来做,下面给一个我写的定时报警的例子 Dim i, x As Integer Private Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long Const SND_SYNC = &H0Private Sub Form_Load() Dim x, i As Integer line: x = Int(Val(InputBox("设定报警时间:", "数据输入"))) If x < 1 Then GoTo line Label1.Caption = "设定报警时间为" & x & "分钟" i = 0 End SubPrivate Sub Timer1_Timer() Dim i As Integer, ret As Long, a As SingleLabel2.Caption = Time i = i + 1 a = i Mod (60 * x) If a = 0 Then ret = sndPlaySound(App.Path & "\" & "111.wav", SND_SYNC) '111.wav是报警声音文件 End If Debug.Print i End Sub
建议你用sndPlaySound这个API函数来做,下面给一个我写的定时报警的例子
Dim i, x As Integer
Private Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
Const SND_SYNC = &H0Private Sub Form_Load()
Dim x, i As Integer
line:
x = Int(Val(InputBox("设定报警时间:", "数据输入")))
If x < 1 Then GoTo line
Label1.Caption = "设定报警时间为" & x & "分钟"
i = 0
End SubPrivate Sub Timer1_Timer()
Dim i As Integer, ret As Long, a As SingleLabel2.Caption = Time
i = i + 1
a = i Mod (60 * x)
If a = 0 Then
ret = sndPlaySound(App.Path & "\" & "111.wav", SND_SYNC) '111.wav是报警声音文件
End If
Debug.Print i
End Sub
sndPlaySound("", SND_SYNC) '111.wav是报警声音文件
或者:
sndPlaySound(VbNullChar, SND_SYNC) '111.wav是报警声音文件