Option Explicit
成都創(chuàng)新互聯(lián)公司主營奉化網(wǎng)站建設(shè)的網(wǎng)絡(luò)公司,主營網(wǎng)站建設(shè)方案,成都app軟件開發(fā),奉化h5重慶小程序開發(fā)搭建,奉化網(wǎng)站營銷推廣歡迎奉化等地區(qū)企業(yè)咨詢
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("輸入時(shí)間(單位:秒)", "輸入", 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; "時(shí)"; M; "分"; S; "秒"
End Sub
Public Class Form1
Private Function ZToFSAll(ByVal ZT As Long) As String
'全存樣式
'從天,時(shí),分,秒整合為秒
Dim T, S, F, M As Integer '天,時(shí),分,秒
Dim T1, S1 As Integer '天,時(shí),分,秒
Dim M1 As String
T = ZT \ 86400
T1 = ZT Mod 86400
S = T1 \ 3600
S1 = T1 Mod 3600
F = S1 \ 60
M = S1 Mod 60
If M 10 Then
M1 = "0" M
Else
M1 = M
End If
ZToFSAll = T "天" S "小時(shí)" F "分鐘" M1 "秒"
End Function
Private Function ZToFSQS(ByVal ZT As Long) As String
'缺損樣式
'從秒分解為天,時(shí),分,秒
Dim T, S, F, M As Integer '天,時(shí),分,秒
Dim T1, S1 As Integer '天,時(shí),分,秒
Dim T2, S2, F2, M2 As String '天,時(shí),分,秒
T = ZT \ 86400
T1 = ZT Mod 86400
S = T1 \ 3600
S1 = T1 Mod 3600
F = S1 \ 60
M = S1 Mod 60
If T = 0 Then
T2 = ""
Else
T2 = T "天"
End If
If S = 0 Then
S2 = ""
Else
S2 = S "小時(shí)"
End If
If F = 0 Then
F2 = ""
Else
F2 = F "分鐘"
End If
M2 = M "秒"
ZToFSQS = T2 S2 F2 M2
End Function
Private Function FSoZT(ByVal T As Integer, ByVal S As Int16, ByVal F As Int16, ByVal M As Int16) As Long
'從天,時(shí),分,秒分解為秒
'T, S, F, M分別為天,時(shí),分,秒
FSoZT = T * 86400 + S * 3600 + F * 60 + M
End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
TextBox1.Text = ZToFSQS(520354) '值為:6天32分鐘34
TextBox1.Text = ZToFSAll(520354) '值為:6天0小時(shí)32分鐘34秒
TextBox1.Text = FSoZT(6, 0, 32, 34) '值為:520354
End Sub。
Dim?day?As?Integer,?hour?As?Integer,?minute?As?Integer,?second?As?Integer,?temp?As?Integer
temp?=?Val(TextBox.Text)
second?=?temp?Mod?60
temp?=?(temp?-?second)?/?60
minute?=?temp?Mod?60
temp?=?(temp?-?minute)?/?60
hour?=?temp?Mod?24
day?=?(temp?-?hour)?/?24
MsgBox?Str(day)??"天"??hour??"小時(shí)"??minute??"分"??second??"秒"
假設(shè)你得到 N 秒
那么,一個(gè)小時(shí)就是 3600 秒,一分鐘就是 60 秒,我們就可以這樣子分割出來 :
小時(shí) hour = N / 3600;
分鐘 minute = ( N - ( hour * 3600 ) ) / 60;
秒 second = N - ( hour * 3600 + minute * 60 );
然后自己按照 hour : minute : second 的格式打印出來就行了 。