用vb程序计算时间差

来源:百度知道 编辑:UC知道 时间:2024/05/27 09:58:03
使用标签、文本框、命令按钮完成。。
* 运行要求:
* 单击“结果”按钮,根据输入的生日,计算今天和生日的时间差(注:使用Datediff函数)。

不知你想做什么?但还是帮你写一下程序,希望真能帮你一点小忙

Option Explicit
'需要控件: command1,label1,text1
Private Sub Command1_Click()
Label1.Caption = "相差" & DateDiff("yyyy", Text1.Text, Date) & "年"
Label1.Caption = Label1.Caption & vbCrLf & _
"相差" & DateDiff("m", Text1.Text, Date) & "月"
Label1.Caption = Label1.Caption & vbCrLf & _
"相差" & DateDiff("d", Text1.Text, Date) & "天"
End Sub

Private Sub Form_Load()
Text1.Text = "1937-7-7"
Command1.Caption = "结果"
End Sub