|
-
Jun 29th, 2000, 08:07 AM
#1
Thread Starter
Member
Hello
I am working on a Time Clock Program and I can find the difference between the clock in time and the clock out time. Is there a vb function to do this? or any thoughts?
My Dream Function would be
HoursWorked = SomeFunction(ClockIn,ClockOut)
If Life could be so good?
Thank you
William
-
Jun 29th, 2000, 09:36 AM
#2
transcendental analytic
It's named Datediff
DateDiff("h", date1, date2)
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Jun 29th, 2000, 09:36 AM
#3
Lively Member
Hi William
Here's a silly one. It won't work if the month rolls-over though. Should be fairly simple to fix.
Make a form with a Command button called Command1, then
Code:
Dim T1 As Date
Function SomeFunction(ByVal InTime As Date, ByVal OutTime As Date) As String
'Returns the difference between InTime and OutTime (in minutes)
InTime = Day(InTime) * 1440 + Hour(InTime) * 60 + Minute(InTime)
OutTime = Day(OutTime) * 1440 + Hour(OutTime) * 60 + Minute(OutTime)
SomeFunction = OutTime - InTime
End Function
Private Sub Command1_Click()
ttl = SomeFunction(T1, Now)
m$ = "Hours: " & vbTab & ttl \ 60 & vbCrLf
m$ = m$ & "Minutes: " & vbTab & ttl Mod 60
MsgBox m$, vbInformation, "Time Taken"
End Sub
Private Sub Form_Load()
T1 = Now
End Sub
Andrew Empson
vb6(ent) SP4
-
Jun 29th, 2000, 09:39 AM
#4
Lively Member
DateDiff
Well, that saves a lot of time. I didn't know about the DateDiff function. Thanks Kedaman
Andrew Empson
vb6(ent) SP4
-
Jun 30th, 2000, 03:22 PM
#5
Thread Starter
Member
Cool, thanks Andrew
But What is The Mod keyword for?
and I didn't know about the DateDiff function either.
William
-
Jun 30th, 2000, 03:33 PM
#6
The Mod keyword is used to divide two numbers and only return the remainder.
-
Jun 30th, 2000, 03:58 PM
#7
Hyperactive Member
FWIW, another variation on the theme
Code:
Function SomeOtherFunction(ClockIn As Date, ClockOut As Date) As Single
Dim Oops As Date
' Return difference between InTime and OutTime (in hours)
If ClockIn > ClockOut THEN
Oops = ClockIn
ClockIn = ClockOut
ClockOut = Oops
End If
SomeOtherFunction = 1440 * (ClockOut - ClockIn)
End Function
[Edited by Mongo on 07-01-2000 at 05:01 AM]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|