Private Declare Function mciSendStringA Lib "winmmdll" _
(ByVal lpstrCommand As String, ByVal lpstrReturnString As String, _
ByVal uReturnLength As Integer, ByVal hwndCallback As Integer) As Integer
Function PlayMidiFile(ByVal MusicFile As String) As Boolean
If SystemIOFileExists(MusicFile) Then
mciSendStringA("stop music", "", 0, 0)
mciSendStringA("close music", "", 0, 0)
mciSendStringA("open " & MusicFile & " alias music", "", 0, 0)
PlayMidiFile = mciSendStringA("play music", "", 0, 0) = 0
End If
End Function
Private Sub Timer1_Tick(ByVal sender As SystemObject, ByVal e As SystemEventArgs) Handles Timer1Tick
If TextBox1Text = TimeOfDay Then
'具体提醒的东西,如你说的播放音乐
PlayMidiFile("自己添加路径")
End If
'时间格式要是这样的16:00:00
'timer的interval要设成1
'你还可以自己细化
End Sub
拉一个按钮控件和一个Timer控件,Timer控件Interval设为1000,Enable设为false。Private Declare Function mciSendString Lib "winmmdll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrRetumString As String, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long
Dim t As Integer '计算时间
Dim s As Integer '提醒间隔时间
Dim mp3file As String 'mp3文件路径
Private Sub Command1_Click()
'停止播放
Call mciSendString("Stop " & mp3file, 0&, 0, 0)
End Sub
Private Sub Form_Load()
t = 0
s = 3 '一小时等于3600秒
mp3file = "D:\yixioump3"
Timer1Enabled = True
End Sub
Private Sub Timer1_Timer()
t = t + 1
If t = s Then
'播放音乐
Call mciSendString("Close" & mp3file, 0&, 0, 0)
Call mciSendString("Open " & mp3file, 0&, 0, 0)
Call mciSendString("play " & mp3file, 0&, 0, 0)
'切换间隔时间
If s = 3600 Then
s = 900
Else
s = 3600
End If
End If
End Sub
以上就是关于利用vb.net实现小闹钟功能全部的内容,包括:利用vb.net实现小闹钟功能、用VB编写一个闹钟程序、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)