扫二维码与项目经理沟通
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流
两种方式自己选用
成都创新互联公司网站建设服务商,为中小企业提供成都网站制作、成都网站建设服务,网站设计,网站改版维护等一站式综合服务型公司,专业打造企业形象网站,让您在众多竞争对手中脱颖而出成都创新互联公司。
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim s As String
s = DateTime.Today.Year()
s = s DateTime.Today.Month()
s = s DateTime.Today.Day()
s = s DateTime.Now.Hour()
s = s DateTime.Now.Minute()
s = s DateTime.Now.Second()
MsgBox(s, vbDefaultButton1, Now())
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim s As String
s = Format(Now(), "yyyymmddhhmmss")
MsgBox(s, vbYes, Now())
End Sub
假设你得到 N 秒
那么,一个小时就是 3600 秒,一分钟就是 60 秒,我们就可以这样子分割出来 :
小时 hour = N / 3600;
分钟 minute = ( N - ( hour * 3600 ) ) / 60;
秒 second = N - ( hour * 3600 + minute * 60 );
然后自己按照 hour : minute : second 的格式打印出来就行了 。
Public Class Form1
Private Function ZToFSAll(ByVal ZT As Long) As String
'全存样式
'从天,时,分,秒整合为秒
Dim T, S, F, M As Integer '天,时,分,秒
Dim T1, S1 As Integer '天,时,分,秒
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 "小时" F "分钟" M1 "秒"
End Function
Private Function ZToFSQS(ByVal ZT As Long) As String
'缺损样式
'从秒分解为天,时,分,秒
Dim T, S, F, M As Integer '天,时,分,秒
Dim T1, S1 As Integer '天,时,分,秒
Dim T2, S2, F2, M2 As String '天,时,分,秒
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 "小时"
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
'从天,时,分,秒分解为秒
'T, S, F, M分别为天,时,分,秒
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小时32分钟34秒
TextBox1.Text = FSoZT(6, 0, 32, 34) '值为:520354
End Sub。
不是 有 函数嘛?
now() 就是 吧
取得 后 再 分离出你所需的,分别赋值 就行了,当然 还是 有 函数的
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流