你需要會用GDI+,也就是那個System.Drawing命名空間下的類.
創(chuàng)新互聯(lián)建站從2013年創(chuàng)立,是專業(yè)互聯(lián)網(wǎng)技術(shù)服務(wù)公司,擁有項目成都網(wǎng)站建設(shè)、做網(wǎng)站網(wǎng)站策劃,項目實施與項目整合能力。我們以讓每一個夢想脫穎而出為使命,1280元永靖做網(wǎng)站,已為上家服務(wù),為永靖各地企業(yè)和個人服務(wù),聯(lián)系電話:18980820575
給你說個思路,設(shè)Timer,到時間就用Form.Invalidate()函數(shù)重畫窗口,在重畫窗口的Form_Paint事件下面編寫代碼得到當(dāng)前時間,再根據(jù)當(dāng)前時間用GDI+畫時鐘.
那是因為你自己沒添加對應(yīng)的控件導(dǎo)致的 你將下面內(nèi)容 復(fù)制到 記事本中 另存為1.frm文件 打開即可 還有你得保證你同目錄下 有Bilp.wav 這個音頻文件
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 1665
ClientLeft = 60
ClientTop = 450
ClientWidth = 1725
LinkTopic = "Form1"
ScaleHeight = 1665
ScaleWidth = 1725
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command2
Caption = "退出"
Height = 375
Left = 960
TabIndex = 3
Top = 840
Width = 615
End
Begin VB.TextBox Text2
Height = 270
Left = 720
TabIndex = 2
Top = 480
Width = 855
End
Begin VB.CommandButton Command1
Caption = "開始"
Height = 375
Left = 120
TabIndex = 1
Top = 840
Width = 615
End
Begin VB.TextBox Text1
Height = 270
Left = 720
TabIndex = 0
Top = 120
Width = 855
End
Begin VB.Timer Timer1
Left = 360
Top = 1200
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "分鐘:"
Height = 180
Left = 120
TabIndex = 5
Top = 480
Width = 540
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "小時:"
Height = 180
Left = 120
TabIndex = 4
Top = 120
Width = 540
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" _
(ByVal IpszName As String, ByVal hModule As Long, ByVal dwflags As Long) As Long
Private Sub Form_Load()
Timer1.Interval = 1000
Timer1.Enabled = False '停止運行定時器
End Sub
'單擊“開始”按紐,輸入定時時間,并啟動定時器
Private Sub Command1_Click()
Command1.Enabled = False
If Val(Text1) 1 Or Val(Text1) 24 Then
MsgBox "小時數(shù)輸入錯誤!", vbExclamation, "提示信息"
Text1 = ""
Text1.SetFocus
Command1.Enabled = True
End If
If Val(Text2) 1 Or Val(Text2) 60 Then
MsgBox "分鐘數(shù)輸入錯誤!", vbExclamation, "提示信息"
Text2 = ""
Text2.SetFocus
Command1.Enabled = True
End If
Timer1.Enabled = True
End Sub
'單擊“結(jié)束”按紐,退出程序
Private Sub Command2_Click()
End
End Sub
'當(dāng)系統(tǒng)時間到達定時時間時,定時播放提示音
Private Sub Timer1_Timer()
If Val(Text1.Text) = Hour(Time) Then
If Val(Text2.Text) = Minute(Time) Then
Call PlaySound(App.Path + "\Bilp.wav", 0, H0)
End If
End If
End Sub
Private Declare Function mciSendStringA Lib "winmm.dll" _
(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 System.IO.File.Exists(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 System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If TextBox1.Text = TimeOfDay Then
'具體提醒的東西,如你說的播放音樂
PlayMidiFile("自己添加路徑")
End If
'時間格式要是這樣的16:00:00
'timer的interval要設(shè)成1
'你還可以自己細化
End Sub
'加個定時器,textbox ,button,label Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Label1.Text = Now
If FF = Now And FF "2001-1-1" And Timer1.Tag = "" Then
Timer1.Tag = "1"
MsgBox("ff")
End If
End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
FF = TextBox1.Text
Timer1.Tag = ""
End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
FF = "2001-1-1"
End Sub'聲音加個 AxMMControl控件 AxMMControl1.DeviceType = "waveaudio" ''''''''定義播放*.wav格式 AxMMControl1.FileName = "c:\1.wav" ''''''''載入文件, AxMMControl1.Command = "open" ''''''''打開載入的文件
AxMMControl1.From = 0 '從頭開始
AxMMControl1.Command = "play"'保存時間,只要設(shè)定時把時間保存到文本文件就行,load 事件中讀取,并對比是不是超時,.
文章名稱:vb點虐
制作鬧鐘 vba設(shè)置鬧鐘提醒
瀏覽路徑:http://muchs.cn/article24/ddcjece.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站營銷、定制網(wǎng)站、自適應(yīng)網(wǎng)站、小程序開發(fā)、用戶體驗、網(wǎng)站改版
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)