VB.Net:组合秒表值

发布于 2025-01-02 08:40:32 字数 376 浏览 0 评论 0原文

我目前有两个秒表(在 VB 2010 程序中运行。我想做的是将它们的值组合在一起,并将它们的结果以格式为 0:00:00 的字符串输出。

我尝试了 Add 方法和 + 方法,但是 ,这失败

简而言之

Dim timer1 As New Stopwatch
Dim timer2 As New Stopwatch

[Assuming the timers were started separately]

Dim elapsed1 As TimeSpan = timer1.Elapsed
Dim elapsed2 As TimeSpan = timer2.Elapsed

elapsed1 += elapsed2

了:有人能帮忙吗?

I currently have two stopwatches ( running in a VB 2010 program. What I would like to do is combine their values together and have their results outputted in a string formatted as 0:00:00.

I tried the Add method and the + method but this fails.

This is in short what I have:

Dim timer1 As New Stopwatch
Dim timer2 As New Stopwatch

[Assuming the timers were started separately]

Dim elapsed1 As TimeSpan = timer1.Elapsed
Dim elapsed2 As TimeSpan = timer2.Elapsed

elapsed1 += elapsed2

Can anyone help?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夜深人未静 2025-01-09 08:40:32

添加此内容:

Dim elapsed3 As TimeSpan = elapsed1.Add(elapsed2)

或阅读 MSDN TimeSpan.Add Method

add this:

Dim elapsed3 As TimeSpan = elapsed1.Add(elapsed2)

or read from MSDN TimeSpan.Add Method

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文