4
A
回答
7
New DateTime(1, 1, 1, 13, 42, 21) > TimeOfDay
或者你可以在#
迹象包围DateTime
表达:
TimeOfDay > #1:42:21 PM#
0
The following sample function can be used to compare time
Function comTime()
Dim t1 As Integer = DateTime.Now.TimeOfDay.Milliseconds
Dim t2 As Integer = DateTime.Now.AddHours(1).Millisecond
If (t1 > t2) Then
MessageBox.Show("t1>t2")
ElseIf (t1 = t2) Then
MessageBox.Show("t1=t2")
Else
MessageBox.Show("t2>t1")
End If
End Function
是沿着这是你正在寻找的东西线?
3
你会找出你的输入时间的格式,然后调用ToString()方法的vb.net对象上,把相同的格式英寸
因此,举例来说,如果你的输入格式为H:MM:SS TT,因为它似乎是在你的情况下,一个方法是做:
Dim compareTime As String = "1:42:21 PM"
If compareTime = DateTime.Now.ToString("h:mm:ss tt") Then
' The times match
End If
如果你想要做一些比较,你应该使用DateTime.Parse()函数将您的输入日期转换为DateTime对象。然后,你可以简单地使用>或<体征:
Dim myCompareTime As DateTime = DateTime.Parse("1:42:21 PM")
If myCompareTime.TimeOfDay > DateTime.Now.TimeOfDay Then
' Compare date is in the future!
End If
0
要比较两个日期时间值的时间部分:
Dim TimeStart as DateTime = #1:42:21 PM#
Dim TimeEnd as DateTime = #2:00:00 PM#
If TimeStart.TimeOfDay < TimeEnd.TimeOfDay Then
Console.WriteLine("TimeStart is before TimeEnd")
End If
6
显示小时,分钟的时间差和秒
Dim TimeEnd As DateTime = #5:00:00 PM#
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim span As System.TimeSpan = TimeEnd.TimeOfDay - DateTime.Now.TimeOfDay
Label1.Text = span.Hours & "hr:" & span.Minutes & "min:" & span.Seconds & "sec"
End Sub
相关问题
- 1. 我怎样才能在vb.net
- 2. 我怎样才能在vb.net
- 3. 我怎样才能在vb.net
- 4. 我怎样才能在vb.net
- 5. 我怎样才能转化为Vb.NET
- 6. 我怎样才能
- 7. 我怎样才能
- 8. 我怎样才能
- 9. 我怎样才能
- 10. 我怎样才能在Ionic2
- 11. 我怎样才能在Zebble
- 12. 我怎样才能在PreferenceScreen
- 13. 我怎样才能在vim
- 14. 我怎样才能在图
- 15. 我怎样才能在Python
- 16. 我怎样才能在DB2
- 17. 我怎样才能在Java
- 18. 我怎样才能在Python
- 19. 我怎样才能在PAM
- 20. 我怎样才能在JSP
- 21. 我怎样才能在RSPEC
- 22. 我怎样才能在logstash
- 23. 我怎样才能在Doctrine2
- 24. 我怎样才能在Python
- 25. 我怎样才能在SAS
- 26. 我怎样才能在laravel
- 27. 我怎样才能在GGPLOT2
- 28. 我怎样才能在AngularJS
- 29. 我怎样才能在Django
- 30. 我怎样才能在Firefox
一些解释会很好。 – pedrofurla 2012-10-15 06:18:00