用VB实现:输入以秒为单位表示的时间,编写程序,将其换算成几日几时几分几秒

用VB实现:输入以秒为单位表示的时间,编写程序,将其换算成几日几时几分几秒,第1张

Option Explicit

Dim Times As String, T As Long

Dim D As Integer, H As Integer, M As Integer, S As Integer

Private Sub Form_Load()

Form1.AutoRedraw = True

Times = InputBox("输入时间(单位:秒)", "输入", 123456)

T = Val(Times)

S = T Mod 60

T = T \ 60

M = T Mod 60

T = T \ 60

H = T Mod 24

D = T \ 24

Print Val(Times)"秒橘码="D"日"H"圆慎哪时"M"分"S"孝键秒"

End Sub

Dim tim As Long

Dim h As Integer, m As Integer, s As Integer

tim = 10000 输入的秒拿旦粗消镇数迟蔽

h = Int(tim / 3600)

m = Int((tim - h * 3600) / 60)

s = tim - h * 3600 - m * 60

MsgBox h &":" &m &":" &s

帮余誉伏你写一下程序,希望真能帮你一点小忙:

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


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/12281160.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-24
下一篇 2023-05-24

发表评论

登录后才能评论

评论列表(0条)

保存