Berikut saya share contoh program untuk menghitung biaya berdasarkan perubahan durasi waktu 30 detik. Dan sangat cocok dikembangkan di dalam pembuatan aplikasi warnet.
Dim Awal, Akhir, Lama As Single
Dim dtkAwal, dtkAkhir As Single
Private Sub Command1_Click()
If Command1.Caption = "Start" Then
Text4.Text = 0
dtkAwal = Time
Awal = Now
Text1.Text = Format(Awal, "hh:mm:ss")
Command1.Caption = "Stop"
ElseIf Command1.Caption = "Stop" Then
Timer1.Enabled = False
Akhir = Now
Lama = Akhir - Awal
Text3.Text = Format(Lama, "hh:mm:ss")
Command1.Caption = "Selesai"
ElseIf Command1.Caption = "Selesai" Then
End
End If
End Sub
Private Sub Timer1_Timer()
If Command1.Caption = "Stop" Then
dtkAkhir = Time 'dtkAkhir adalah waktu terkini
If Second(dtkAkhir - dtkAwal) = 30 Then
dtkAwal = dtkAkhir 'Assignment dtkAkhir ke dtkAwal
Text4.Text = Format(Text4.Text + 1100, "#,#") 'Update biaya
End If
Text2.Text = Format(Now, "hh:mm:ss")
Text3.Text = Format(Now - Awal, "hh:mm:ss")
End If
End Sub