vb点虐 制作闹钟 vba设置闹钟提醒
怎样用vb点虐 作一个指针转动的钟表?(可设置时间日期,有闹铃功能)
你需要会用GDI+,也就是那个System.Drawing命名空间下的类.
创新互联建站从2013年创立,是专业互联网技术服务公司,拥有项目成都网站建设、做网站网站策划,项目实施与项目整合能力。我们以让每一个梦想脱颖而出为使命,1280元永靖做网站,已为上家服务,为永靖各地企业和个人服务,联系电话:18980820575
给你说个思路,设Timer,到时间就用Form.Invalidate()函数重画窗口,在重画窗口的Form_Paint事件下面编写代码得到当前时间,再根据当前时间用GDI+画时钟.
VB 闹钟代码
那是因为你自己没添加对应的控件导致的 你将下面内容 复制到 记事本中 另存为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 "小时数输入错误!", vbExclamation, "提示信息"
Text1 = ""
Text1.SetFocus
Command1.Enabled = True
End If
If Val(Text2) 1 Or Val(Text2) 60 Then
MsgBox "分钟数输入错误!", vbExclamation, "提示信息"
Text2 = ""
Text2.SetFocus
Command1.Enabled = True
End If
Timer1.Enabled = True
End Sub
'单击“结束”按纽,退出程序
Private Sub Command2_Click()
End
End Sub
'当系统时间到达定时时间时,定时播放提示音
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
利用vb点虐 实现小闹钟功能
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要设成1
'你还可以自己细化
End Sub
跪求用vb点虐 做一个小闹钟!!
'加个定时器,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 事件中读取,并对比是不是超时,.
当前文章:vb点虐 制作闹钟 vba设置闹钟提醒
当前URL:http://ybzwz.com/article/ddcjece.html