Dim ydsj As Date
Private Sub Form_Load()
ydsj = InputBox("请输入约定时间!格式如括号里:(年号/月号/日子)或者又如括号里:(年号/月号/日子空格小时:分钟:秒数)如下格式:", , "2011/1/1 00:00:00")
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
Dim dqnyr As Date
If Now < ydsj Then
sysj = ydsj - Now
syn = Year(ydsj) - Year(Now) - 1
If Year(ydsj) = Year(Now) Then syn = syn + 1 '年
syy = 12 - Month(Now) & "+" & Month(ydsj) - 1 & "=" & 12 - Month(Now) + Month(ydsj) - 1
If Year(ydsj) = Year(Now) Then
syy = Month(ydsj) - Month(Now) - 1
If Month(ydsj) = Month(Now) Then syy = syy + 1
End If '月
dqnf = Year(Now)
dqyf = Month(Now)
If dqyf = 12 Then
dqyf = 1
dqnf = dqnf + 1
End If
dqnyr = dqnf & "-" & dqyf & "- " & 1
syr = Fix(dqnyr - Now) & "+" & Day(ydsj) - 1 & "=" & Fix(dqnyr - Now) + Day(ydsj) - 1
If Year(ydsj) = Year(Now) And Month(ydsj) = Month(Now) Then syr = Fix(dqnyr - Now) - Fix(dqnyr - ydsj) '日
nowh = Format(Now, "hh")
nowm = Format(Now, "nn")
nows = Format(Now, "ss")
now1 = Date + 1
dqsyhms = now1 - Now
nowsyh = Format(dqsyhms, "hh")
nowsym = Format(dqsyhms, "nn")
nowsys = Format(dqsyhms, "ss")
ydhms = Format(ydsj, "hh:mm:ss")
ydh = Format(ydsj, "hh")
ydm = Format(ydsj, "nn")
yds = Format(ydsj, "ss")
syh = nowsyh & "+" & ydh & "=" & Val(nowsyh) + Val(ydh)
bzd = Format(ydsj, "yyyy-m-d")
If Format(Now, "yyyy-mm-dd") = Format(ydsj, "yyyy-mm-dd") Then
syh = ydh - nowh
End If '时
sym = nowsym & "+" & ydm & "=" & Val(nowsym) + Val(ydm)
If Format(Now, "yyyy-mm-dd hh") = Format(ydsj, "yyyy-mm-dd hh") Then
sym = ydm - nowm
End If '分
sys = nowsys & "+" & yds & "=" & Val(nowsys) + Val(yds)
If Format(Now, "yyyy-mm-dd hh:nn") = Format(ydsj, "yyyy-mm-dd hh:nn") Then
sys = yds - nows
End If '秒
Label1.Caption = "当前时间是:" & Now & " 距 " & ydsj & "还有(" & syn & ")个年头+(" & syy & ")个月份+(" & syr & ")个日子+(" & syh & ")小时+(" & sym & ")分钟+(" & sys & ")秒;合计=: (" & sysj & ")天!"
ElseIf Now = ydsj Then
Label1.FontSize = 28
Label1.ForeColor = &HFF&
Label1.Caption = ydsj & "到了!祝您在以后的日子里万事如意,身体安康!88!88!"
Timer1.Interval = 8888
ElseIf Now > ydsj Then
Label1.FontSize = 28
Label1.ForeColor = &HFF0000
Label1.Caption = ydsj & "已经过了!祝您万事如意,身体安康!"
End If
End Sub