用VB编写一程序,要求用户输入通过界面输入自己的出生年、月、日,程序计算自该日起往后10000天
2个回答
展开全部
Private Sub Command1_Click()
Dim s As String, d As Date
s = InputBox("请输入你的出生年月日" & vbCrLf _
& "格式为yyyy-m-d" & vbCrLf & "如:1990-6-5")
If IsDate(s) Then
d = CDate(s)
MsgBox "你的生日是" & d & vbCrLf _
& "这个日期起往后10000天是" & d + 10000 & vbCrLf _
& "今天离这个日期有" & DateDiff("d", Now, d + 10000) & _
"天,合" & DateDiff("h", Now, d + 10000) & "小时"
Else
MsgBox "日期输入错误!"
End If
End Sub
展开全部
Private Sub Command1_Click()
Dim a As Date
Dim b As Date
Dim c As Date
Dim d As Long
Dim e As Long
a = Text2.Text & "/" & Text3.Text & "/" & Text1.Text
b = DateAdd("d", 10000, a)
Label1.Caption = "生日10000天后是" & b
c = Date
d = DateDiff("d", c, b)
e = d * 24 - DateDiff("h", Now(), b & " 00:00:00")
Label2.Caption = "还有" & d & "天" & e & "小时"
End Sub
Dim a As Date
Dim b As Date
Dim c As Date
Dim d As Long
Dim e As Long
a = Text2.Text & "/" & Text3.Text & "/" & Text1.Text
b = DateAdd("d", 10000, a)
Label1.Caption = "生日10000天后是" & b
c = Date
d = DateDiff("d", c, b)
e = d * 24 - DateDiff("h", Now(), b & " 00:00:00")
Label2.Caption = "还有" & d & "天" & e & "小时"
End Sub
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询