如何使用循环启动秒表,并在VB.NET中结束
所以我需要启动一个秒表,按下一个按钮,它也会启动一个循环。循环完成后,如何停止秒表?下面的例子如何使用循环启动秒表,并在VB.NET中结束,vb.net,visual-studio-2010,Vb.net,Visual Studio 2010,所以我需要启动一个秒表,按下一个按钮,它也会启动一个循环。循环完成后,如何停止秒表?下面的例子 Private Sub btnStart... n = 0 While n < 1001 n += 1 (Contents of loop go here) End While Stop stopwatch lbl1.Text = stopwatchvalue 专用子btnStart。。。 n=0 而n
Private Sub btnStart...
n = 0
While n < 1001
n += 1
(Contents of loop go here)
End While
Stop stopwatch
lbl1.Text = stopwatchvalue
专用子btnStart。。。
n=0
而n<1001
n+=1
(循环的内容转到此处)
结束时
秒表
lbl1.Text=秒表值
对不起,如果这没有任何意义(我对这一切都相当陌生)。如果有什么我能帮忙的,我洗耳恭听
非常感谢大家,所以这一切都非常有用。您可以启动和停止秒表,然后像这样以毫秒为单位读取经过的时间
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim sw As New Stopwatch
sw.Start()
Dim n As Integer = 0
Do While n < 1001
n += 1
'(Contents of loop go here)
Loop
sw.Stop()
lbl1.Text = sw.ElapsedMilliseconds.ToString
End Sub
Private子按钮1\u单击(发送者作为对象,e作为事件参数)处理按钮1。单击
将sw调暗为新秒表
sw.Start()
尺寸n为整数=0
当n<1001时,不要这样做
n+=1
'(循环的内容转到此处)
环
sw.Stop()
lbl1.Text=sw.elapsedmillisons.ToString
端接头
这在理论上是可行的。您知道秒表类吗?()工作得很好!谢谢你快速准确的回复。这比我在谷歌上看到的要容易得多,有时候你只需要一个专家来解决问题!