如果时间 2 大于时间 1 的 9 小时,则为真
If time2 is greater than 9 hours to time 1 then true
我正在为 VB.NET 写一个时间进出的代码。我的问题是,当 time2
到 time1
的时间超过 9 小时时,我需要在这种情况下给出真实的陈述。
tat.Text = myreader.Item("Status").ToString
abs = myreader.Item("Time_In").ToString
abs1 = myreader.Item("Time_In").ToString
EndTime = TimeOfDay.ToString("h:mm:ss tt")
StartTime = TimeOfDay.ToString("h:mm:ss tt")
' Main.oras.Text = StartTime
gtg2 = abs
gtg3 = gtg2.AddHours(9)
gtg4 = abs1
If gtg3 > gtg4 Then
Label32.BackColor = Color.Red
End If
试试这个:
Dim dt1 = #1/4/2019 8:00#
Dim dt2 = #1/4/2019 20:00#
If dt2 - dt1 > TimeSpan.FromHours(9) Then
MsgBox("Time is more than 9 hours")
Else
MsgBox("Time is less than 9 hours")
End If
如果结束时间距开始时间超过 9 小时,我创建了此函数:
Private Function GreaterThan9Hours(ByVal StartTime As DateTime, ByVal EndTime As DateTime) As Boolean
If EndTime - StartTime > TimeSpan.FromHours(9) Then
Return True
Else
Return False
End If
End Function
我正在为 VB.NET 写一个时间进出的代码。我的问题是,当 time2
到 time1
的时间超过 9 小时时,我需要在这种情况下给出真实的陈述。
tat.Text = myreader.Item("Status").ToString
abs = myreader.Item("Time_In").ToString
abs1 = myreader.Item("Time_In").ToString
EndTime = TimeOfDay.ToString("h:mm:ss tt")
StartTime = TimeOfDay.ToString("h:mm:ss tt")
' Main.oras.Text = StartTime
gtg2 = abs
gtg3 = gtg2.AddHours(9)
gtg4 = abs1
If gtg3 > gtg4 Then
Label32.BackColor = Color.Red
End If
试试这个:
Dim dt1 = #1/4/2019 8:00#
Dim dt2 = #1/4/2019 20:00#
If dt2 - dt1 > TimeSpan.FromHours(9) Then
MsgBox("Time is more than 9 hours")
Else
MsgBox("Time is less than 9 hours")
End If
如果结束时间距开始时间超过 9 小时,我创建了此函数:
Private Function GreaterThan9Hours(ByVal StartTime As DateTime, ByVal EndTime As DateTime) As Boolean
If EndTime - StartTime > TimeSpan.FromHours(9) Then
Return True
Else
Return False
End If
End Function