большое спасибо за ответы ... наконец-то я закончил свое приложение секундомера ... я сделал это, и мой лидер дал мне 8 из 10 ... это очень хорошо для меня, вот форма дизайна и код
visual basic 2012, секундомер с кнопкой кругаКак форма 'Dim SW As New System.Diagnostics.Stopwatch ()
Dim lapcount As Integer
Dim lastlap As String
'スタート・ストップボタン
Private Sub btnStart_Click(sender As Object, e As EventArgs) Handles btnStart.Click
If btnStart.Text = "Start" Then
sw.Start() '時間計測開始
Timer1.Interval = 10
Timer1.Enabled = True
btnStart.Text = "Stop"
Else
sw.Stop() '時間計測一時停止
Timer1.Enabled = False
btnStart.Text = "Start"
End If
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
lblTime.Text = sw.Elapsed.ToString("hh\:mm\:ss\:ff")
End Sub
'cancel / reset ボタン
Private Sub btnReset_Click(sender As Object, e As EventArgs) Handles btnReset.Click
sw.Reset() '初期状態にする
Timer1.Enabled = False
lblTime.Text = "00:00:00:00"
ListView1.Items.Clear()
btnStart.Text = "Start"
lapcount = 0
End Sub
'ラップボタン
Private Sub btnLap_Click(sender As Object, e As EventArgs) Handles btnLap.Click
Dim lap = sw.Elapsed.ToString("hh\:mm\:ss\:fff") ' ラップ時間を変数に代入
lapcount += 1
Dim i As Integer = ListView1.Items.Count
If i <= 0 Then ' ListviewのアイテムのValueが0または0より小さければ
ListView1.Items.Add(CStr(lapcount), i)
ListView1.Items(i).SubItems.Add(lap) 'アイテムとサブアイテム表示
ListView1.Items(i).SubItems.Add(lap)
Else '文字列となっている結果時間を整数型に変換する/ // ラップ経過時間を取得するため
Dim day As Integer = 0
Dim hr As Integer = CInt(Strings.Left(lap, 2))
Dim min As Integer = CInt(Strings.Mid(lap, 4, 2))
Dim sec As Integer = CInt(Strings.Mid(lap, 7, 2))
Dim milli As Integer = CInt(Strings.Mid(lap, 10, 3))
Dim dayy As Integer = 0
Dim hrr As Integer = CInt(Strings.Mid(lastlap, 19, 2))
Dim minn As Integer = CInt(Strings.Mid(lastlap, 22, 2))
Dim secc As Integer = CInt(Strings.Mid(lastlap, 25, 2))
Dim millii As Integer = CInt(Strings.Mid(lastlap, 28, 3))
'現在のラップ時間に直前に記憶したラップ時間を引き、1回目から2回目のラップボタン押下までの経過時間を図る
Dim answer = createtimespan(day, hr, min, sec, milli) - createtimespan(dayy, hrr, minn, secc, millii)
Dim ansTS = answer.ToString("hh\:mm\:ss\:fff") 'ミリ秒3桁まで表示するように指定
ListView1.Items.Add(CStr(lapcount), i)
ListView1.Items(i).SubItems.Add(lap)
ListView1.Items(i).SubItems.Add((ansTS).ToString) 'ラップ時間の表示
End If
lastlap = ListView1.Items(i).SubItems(1).ToString '直前のラップタイムを記憶
End Sub
Private Function createtimespan(ByVal days As Integer, ByVal hours As Integer, ByVal minutes As Integer, _
ByVal seconds As Integer, ByVal milliseconds As Integer) As TimeSpan
Dim elapsedTime As New TimeSpan(days, hours, minutes, seconds, milliseconds)
Return (elapsedTime)
End Function
Конечный класс