Möchte die gestoppte Zeit dauerhaft speichern (my.settings.klZeitpaket),nachdem das Programm beendet wurde. Nach erneutem Öffnen möchte ich mit der alten Zeit weitermachen usw.. Doch jedesmal beginnt bei mir die Stoppuhr bei 0. Wer kommt auf den Fehler?
Public Class Form1
Private TS As TimeSpan
Private StoppUhr As New Stopwatch
Public start, endzeit, heutetag As Date
Public kat As String
Dim d1 As New Date
Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) _
Handles Timer1.Tick
TS = StoppUhr.Elapsed
Label1.Text = Format(TS.Minutes, "00") & ":" & Format(TS.Seconds, _
"00") & "." & Mid(Format(TS.Milliseconds, "000"), 1, 2)
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) _
Handles Me.Load
heutetag = Date.Today
Label3.Text = Format(heutetag)
Label2.Text = Format(TimeOfDay)
Timer1.Interval = 20
Label1.Text = Format(My.Settings.klZeitpaket.Minutes, "00") & ":" & _
Format(My.Settings.klZeitpaket.Seconds, "00") & "." & Mid(Format( _
My.Settings.klZeitpaket.Milliseconds, "000"), 1, 2)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As _
System.EventArgs) Handles Button1.Click
StoppUhr.Start()
Me.Timer1.Start()
start = Now
ComboBox1.Visible = False
Button5.Visible = False
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As _
System.EventArgs) Handles Button2.Click
Button1.Visible = True
Button2.Visible = False
StoppUhr.Stop()
TS = StoppUhr.Elapsed
Timer1.Stop()
endzeit = Now
' Label1.Text = Format(TS.Minutes, "00") & ":" & Format(TS.Seconds,
' "00")
My.Settings.klZeitpaket = TS
Label1.Text = Format(TS.Minutes, "00") & ":" & Format(TS.Seconds, "00") _
& "." & Mid(Format(TS.Milliseconds, "000"), 1, 2)
My.Settings.Save()
ComboBox1.Visible = True
'(d1.ToString("hh:mm:ss")
' d1 = d1.AddMinutes(50)
End Sub
Private Sub Button4_Click_1(ByVal sender As System.Object, ByVal e As _
System.EventArgs) Handles Button4.Click
StoppUhr.Reset()
My.Settings.klZeitpaket = Nothing
TS = Nothing
My.Settings.Save()
Label1.Text = "00:00.00"
End Sub
<pre><code> |