Public b8_flag As Integer = 0
Dim startTime As DateTime
Dim ts As TimeSpan
Private Sub Button8_Click(sender As Object, e As EventArgs) Handles Button8.Click
Dim startDt As DateTime = DateTime.Now
If b8_flag = 0 Then
Button8.Text = "測定停止"
With ToolStripStatusLabel1
.Text = "測定中"
.BackColor = Color.Yellow
End With
ToolStripStatusLabel2.Text = "測定時間:00:00:00"
startTime = DateTime.Now
Threading.Thread.Sleep(100)
Timer2.Start()
b8_flag = 1
Else
With ToolStripStatusLabel1
.Text = "測定停止"
.BackColor = SystemColors.Control
End With
sw.Stop()
Timer2.Enabled = False
'ToolStripStatusLabel2.Text = "測定時間:00:00:00"
b8_flag = 0
End If
End Sub
Private Sub Timer2_Tick(sender As Object, e As EventArgs) Handles Timer2.Tick
ToolStripStatusLabel2.Text = "測定時間:" & sw.Elapsed.Hours.ToString("00") & ":" & sw.Elapsed.Minutes.ToString("00") & ":" & sw.Elapsed.Seconds.ToString("00")
ts = Now.Subtract(startTime) ' 経過時間算出
ToolStripStatusLabel4.Text = "経過時間:" & ts.TotalMinutes.ToString
ts = DateTime.Now - startTime
ToolStripStatusLabel4.Text = String.Format("{0:00}:{1:00}:{2:00}", ts.Hours, ts.Minutes, ts.Seconds)
End Sub