开发者

Being able to add times such as 2:39 instead of decimal numbers using VB

I am creating a Time Sheet Calculator Application and just need to find out how to add numbers that are in hourly form. For example 2:39 (two hours and thirty nine minutes). I know how t开发者_高级运维o create code for simple addition of decimal numbers, but does VB 2010 have some kind of way of adding hours and returning a number in hourly form. Thank you


Try the TimeSpan type ....

Dim ts1 As New TimeSpan(2, 39, 0)
Dim ts2 As New TimeSpan(3, 40, 0)
Dim ts3 = ts1 + ts2
MessageBox.Show(ts3.ToString)

i.e 2:39 + 3:40 = 6:19

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜