VB.net 中如何将秒数转换为分钟或者小时
假设你得到 N 秒
创新互联专注于那曲企业网站建设,成都响应式网站建设公司,电子商务商城网站建设。那曲网站建设公司,为那曲等地区提供建站服务。全流程定制开发,专业设计,全程项目跟踪,创新互联专业和态度为您提供的服务
那么,一个小时就是 3600 秒,一分钟就是 60 秒,我们就可以这样子分割出来 :
小时 hour = N / 3600;
分钟 minute = ( N - ( hour * 3600 ) ) / 60;
秒 second = N - ( hour * 3600 + minute * 60 );
然后自己按照 hour : minute : second 的格式打印出来就行了 。
vb.net怎样把小时、分钟、秒转换为分钟
这个简单。dim time1 datetime ="1:20:30"dim h as int =time1.tostring("hh")dim M as int =time1.tostring("MM")dim S as int=time1.tostring("ss")dim SUMfen as double=h*60+M+S/60SUMfen就是最后 的结果。语法你自己修改下。纯手打。
VB.NET 如何将秒转化为小时,分钟,秒的形式
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。
VB求解~设计一个代码将秒数转化为小时,分钟~
Dim Bb(1 To 3) As String 'bb1-3对应时、分、秒
Bb(1) = Val(Text1.Text) \ 3600
Bb(2) = Val(Text1.Text) \ 60
Bb(3) = Val(Text1.Text) - Val(Bb(2)) * 60
If Bb(2) = 60 Then Bb(2) = Bb(2) - 60 * Bb(1)
Label1.Caption = Val(Bb(1)) " 时 " Val(Bb(2)) " 分 " Val(Bb(3)) " 秒"
看下是你说的不?
若不对请指正。谢谢
怎样把VB中timer(计时器控件)的单位MS转换成别的单位,比如毫秒转换成分钟?
Dim i As Long '新的计时器变量Private Sub Form_Load()
Timer1.Interval = 1000
Timer1.Enabled = True
End SubPrivate Sub Timer1_Timer()
i = i + 1 '计时器按一秒累加一次
If i 60 Then Exit Sub '如果不够一分钟 则不执行下面的过程 60 单位是秒 当然可以改成 3600 一个小时
i = 0 '当够一分钟了 计时器归0重新计算
MsgBox "一分钟到了" '需要执行的代码
'......................
'......................End Sub
VB中在文本框输入秒数,以小时,分,秒形式显示在运行时如何操作?
Private Sub Command1_Click()
s = CLng(InputBox("请输入秒钟数:"))
s1 = s
h = s \ 3600
s = s Mod 3600
m = s \ 60
s = s Mod 60
MsgBox (s1 "秒=" h "小时" m "分" s "秒")
End Sub
本文题目:vb.net秒化分钟 vb时分秒转换
网页URL:http://lswzjz.com/article/hgodie.html