'加個定時器,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"'保存時間,只要設定時把時間保存到文本文件就行,load 事件中讀取,并對比是不是超時,.
首先在form1上建立三個命令按鈕,分別為command1(打開預啟動的文件);command2(設定時間的按鈕);第三個command3(即可啟動)按鈕可有可無;一個label1用來顯示你預打開的文件名的路徑;一個lbltime用來顯示現在的時間;還有一個commondialog,它在工程菜單的部件中,你可把它加到工具箱中再開始使用;關于對話框你不必自己建,只要從應用程序向導中添加即可;一個timer,它的interval=500。 其次在form1的屬性中設置為:startupposition=2-centerscreen和maxbutton=false;label1的屬性中設置為:alignment=2-center。 外觀大致是如圖所示: 下面我們開始編程: OptionExplicit DimAlarmTime '申明變量 --------- PrivateSubCommand1_Click() Calldialog '調用dialog子程序 EndSub -------- PrivateSubCommand2_Click() AlarmTime=InputBox(“請輸入你想設定的時間,例如(19:12:00)",“小鬧鐘") IfAlarmTime=“"ThenExitSub IfNotIsDate(AlarmTime)Then MsgBox“你所輸入的不是時間格式,請重試!",,“Wrong" Else AlarmTime=CDate(AlarmTime) EndIf '判斷輸入的是否可轉換成time格式 'isdate函數是判斷輸入的是否可轉換成date格式 EndSub -------------- PrivateSubCommand3_Click() Calldeng '調用deng子程序 EndSub --------------- PrivateSubForm_Click() frmAbout.Show '顯示關于對話框 EndSub ------------- PrivateSubForm_Load() Command3.Enabled=0 AlarmTime=“" '初始化時command3為不可用的 EndSub --------------- PrivateSubForm_Resize() IfWindowState=1Then mintime else caption=“小鬧鐘" EndIf '如果窗口被最小化,則調用mintime程序 EndSub --------------- PrivateSubmintime() Caption=Format(Time,“longTime") '使用長時間格式來顯示時間 EndSub --------------- PrivateSubTimer1_Timer() IflblTime.CaptionCStr(Time)Then lblTime.Caption=Time EndIf '顯示時間每秒鐘的變化 IfTime=AlarmTimeThen Calldeng EndIf '判斷如果現在的時間超過了設定的時間,則調用deng子程序 IfWindowState=1Then IfMinute(CDate(Caption))Minute(Time)Then mintime EndIf EndIf '最小化時顯示時間每分鐘的變化 EndSub ------------- Subdialog() CommonDialog1.Flags=cdlCFBoth CommonDialog1.ShowOpen Label1.Caption=CommonDialog1.filename IfLabel1“"Then Command3.Enabled=-1 Else ExitSub EndIf '把打開的文件名給于label1 '如果label1不為空時,則command3即可用 EndSub -------------- Subdeng() Dimss ss=Shell(Label1.Caption,1) End '啟動指定的文件,并且結束小鬧鐘程序 EndSub 最后在about對話框中要提的是:在form_load中app.title表示你的應用程序的名字;app.major、minor、revision是關于應用程序的版本信息;lblDescription.Caption用于對本程序的一些說明描述之類的話;lblDisclaimer.Caption用于版權信息或警告等。 好了,至此我們已完成了一個簡單的VB程序的編寫,希望你能設計出更好的鬧鐘程序來!
你需要會用GDI+,也就是那個System.Drawing命名空間下的類.
給你說個思路,設Timer,到時間就用Form.Invalidate()函數重畫窗口,在重畫窗口的Form_Paint事件下面編寫代碼得到當前時間,再根據當前時間用GDI+畫時鐘.