fungsi Selisih waktu dengan VB

Kemaren…. bingung,… mau buat selisih waktu untuk sistem penggajian lembur,.. tadinya pengen pake algoritma aja, jadi gatergantung sama fungsi,.. tapi tanya sana tanya sini,.. kayak na nie fungsi lebih tepat..

Berikut fungsi source code nya di VB, kali aja berguna.. loe, cuman bikin satu command button satu aja,.. trus loe lihat aja kode nya, pasti ngerti.🙂

Private Sub Command1_Click()
‘ MsgBox (TimeValue(“14:00”) – TimeValue(“13:00”))
MsgBox tm_Seconds_to_Time(tm_Time_to_Second2(“14:21:00”) – tm_Time_to_Second2(“13:27:00”))
End Sub

Function tm_Time_to_Second2(prTime As String) As Long

If IsNull(prTime) Then
tm_Time_to_Second2 = 0
Exit Function
End If

Dim menit As Long
Dim detik As Long
Dim jam As Long
Dim DURASI As Long

detik = Right(prTime, 2)
menit = CCur(Mid(prTime, 4, 2)) * 60
jam = CCur(Left(prTime, 2)) * 60 * 60
DURASI = detik + menit + jam
tm_Time_to_Second2 = DURASI
End Function

Function tm_Seconds_to_Time(Value As Long) As String
Dim Hour, Minutes, Seconds As Double
Dim hourzero, minzero, seczero As String
If Not IsNumeric(Value) Then Exit Function

Hour = Value / 3600
Hour = Fix(Hour)
Minutes = (Value – (Hour * 3600)) / 60
Minutes = Fix(Minutes)
Seconds = (Value – (Hour * 3600) – (Minutes * 60))

hourzero = “”
If (Hour < 10) Then hourzero = “0”
minzero = “”
If (Minutes < 10) Then minzero = “0”
seczero = “”
If (Seconds < 10) Then seczero = “0”

tm_Seconds_to_Time = hourzero & Hour & “:” & minzero & Minutes & “:” & seczero & Seconds
End Function

Salam – Sidabutar

Leave a comment

No comments yet.

Comments RSS TrackBack Identifier URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s