Geçen Süreyi Hesaplama
Girilen Başlangıç saatinden şu anki saate kadar geçen zamanı hesaplayacağız. Formunuza 1 adet Timer, 2 adet TextBox ve Button ekleyin. Aşağıdaki şekilleri inceleyin.
Şekil 1
Şekil 2
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
TextBox1.Text = Format(Now, "Long Time")
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Timer1.Enabled = True
Timer1.Interval = 1000
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Timer1.Enabled = False
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim gecensure As TimeSpan = New TimeSpan(0, 0, 0, 0, 0)
Dim baslangic As String
Dim bitis As Date
baslangic = TextBox1.Text
bitis = TimeOfDay
gecensure = gecensure.Add(bitis.Subtract(baslangic))
TextBox2.Text = gecensure.ToString
End Sub
End Class
Bir sonraki makalede buluşmak üzere. Bahadır ŞAHİN