vb点虐 转换时间的简单介绍

VB点虐 中如何将秒数转换为分钟或者小时

假设你得到 N 秒

成都创新互联从2013年创立,先为善右等服务建站,善右等地企业,进行企业商务咨询服务。为善右企业网站制作PC+手机+微官网三网同步一站式服务解决您的所有建站问题。

那么,一个小时就是 3600 秒,一分钟就是 60 秒,我们就可以这样子分割出来 :

小时 hour = N / 3600;

分钟 minute = ( N - ( hour * 3600 ) ) / 60;

秒 second = N - ( hour * 3600 + minute * 60 );

然后自己按照 hour : minute : second 的格式打印出来就行了 。

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如何把数值转化为时间格式

vb把数值转化为时间格式:

VB点虐 中 取系统时间

Dim datestr As String = ""

datestr = Format(Now(), "yyyy/MM/dd H:mm:ss ffff")

用户定义的日期/时间格式(Format 函数)

转化代码:

Dim t As Integer, t1 As Integer, t2 As Integer, s As String

Dim tim As Date

Dim i As Integer, j As Integer

Private Sub Command1_Click()

s = InputBox("分钟数:", "输入", 67)

If s = "" Then Exit Sub

t = Val(s)

If t = 0 Then Exit Sub

t1 = t \ 60

t2 = t Mod 60

s = t1 ":" t2

tim = Format(s, "hh:mm:ss")

Text1.Text = tim

Timer1.Interval = 1000

Timer1.Enabled = True

End Sub

Private Sub Timer1_Timer()

Dim tt1 As Integer, tt2 As Integer, tt3 As Integer, tt As String

tt = Text1.Text

tt1 = Val(Left(tt, Len(tt) - 6))

tt2 = Val(Mid(tt, Len(tt) - 4, 2))

tt3 = Val(Right(tt, 2))

tt3 = tt3 - 1

If tt3 0 Then tt3 = 59: tt2 = tt2 - 1

If tt2 0 Then tt2 = 59: tt1 = tt1 - 1

If tt1 0 Then Timer1.Enabled = False: Exit Sub

tt = tt1 ":" tt2 ":" tt3

tim = Format(tt, "hh:mm:ss")

Text1.Text = tim

End Sub

vbnet中怎样把时间设为24时制

将时间转换为指定的字符串格式用:Now.ToString("yyyyMMddHHmmss")就Ok了。

例如:年份用小写yyyy(大写不识别),大写MM识别为月份,小写mm识别为分钟,日期天为大写DD(小写不识别),

小时大写HH识别为24小时制,小写hh识别为12小时制,秒用小写ss(大写不识别)

补充:Visual Basic.NET是基于微软.NET Framework之上的面向对象的编程语言。

其在调试时是以解释型语言方式运作,而输出为EXE程序是是以编译型语言方式运作。

可以看作是Visual Basic在.Net Framework平台上的升级版本,增强了对面向对象的支持。大多的VB.Net程序员使用Visual Studio .Net作为IDE(integrated development environment).SharpDevelop是另一种可用的开源的IDE。

VB.Net需要在.Net Framework平台上才能执行。


文章题目:vb点虐 转换时间的简单介绍
标题链接:http://azwzsj.com/article/ddcihsc.html