开发者

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

开发者 https://www.devze.com 2023-03-20 10:26 出处:网络
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

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

精彩评论

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