新网创想网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
'加个定时器,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 事件中读取,并对比是不是超时,.
Dim hour, min, sec As Integer
Private Sub Command1_Click()
If Command1.Caption = "开始计时" Then
Command1.Caption = "停止计时"
Timer1.Enabled = True
Else
If Command1.Caption = "停止计时" Then
Command1.Caption = "开始计时"
Timer1.Enabled = False
End If
End If
End Sub
Private Sub Form_Load()
hour = 0
min = 0
sec = 0
Label1.Caption = Format(hour, "00") ":" Format(min, "00") ":" Format(sec, "00")
End Sub
Private Sub Timer1_Timer()
sec = sec + 1
If sec 59 Then
sec = 0
min = min + 1
If min 59 Then
min = 0
hour = hour + 1
End If
End If
Label1.Caption = ""
Label1.Caption = Format(hour, "00") ":" Format(min, "00") ":" Format(sec, "00")
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要设成1
'你还可以自己细化
End Sub
我从来不加到Controls中也能用,大概这个不是从Control继承而来的,所有非可视部件(即组件)估计都不需要add。
1、时间可以直接比较大小,定义两个时间的变量,直接使用或者即可判断,跟数据大小判断是一样的
2、时间差值,可以使用DateDiff函数进行
3、比如取一个现在的时间now,使用Year、month、day、hour、min、sec函数可以取到now的年份、月、日、小时、分钟和秒
'添加一个label标签名字label1 用来显示时间
'再添加一个timer控件 名字timer1 interval属性=1000 用来计时
'窗体添加代码
Dim t As Date '用来记录时间
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As _
System.EventArgs) Handles Timer1.Tick
t = t.AddSeconds(1)
Label1.Text = "登录时间:" t.TimeOfDay.ToString
End Sub