I have too written software for calculating hours. It was in filePro, and
not VB, but here would be a snippet of how I would do it:
If val(objFlds("fldHours")) <= 40 Then
objFields("fldGross") = Round(val(objFlds("fldHours")) *
val(objFlds("fldRate")), 2)
Else
objFields("fldGross") = 40 * val(objFlds("fldRate")) + _
val(objFlds("fldHours")) - 40 * ((val(objFlds("fldRate")) * 1.5), 2)
End If
You calcuation on the first line of else needs to be set at 40, because if
not, then if I worked 45 hours you are paying me for 45 at reg pay, and 5 at
OT pay. On the second line of the else, You need to have it calc the OT Rate
before you multiply it by the number of OT hours.
--
Travis Conway
"Kingbarry2000" <ki*************@hotmail.com> wrote in message
news:xZ***********************@news3.calgary.shaw. ca...
If UCase(objFlds("fldHours")) <= "40" Then
Use numerics, not alpha
try If val(objFlds("fldHours")) <= 40 Then
objFlds("fldGross") = Round(val(objFlds("fldHours")) *
val(objFlds("fldRate")), 2)
Else
objFlds("fldGross") = Round(val(objFlds("fldHours")) *
val(objFlds("fldRate")) + _
val(objFlds("fldHours")) - 40 *
val(objFlds("fldRate")) * 1.5, 2)
"J Buchman" <ja*********@comcast.net> wrote in message
news:3K********************@comcast.com...
I'm trying to write a statement in VB 6 that will give me the overtime pay.
It needs to compute the first 40 hours at the normal pay rate, then any
hours over 40 at rate * 1.5, then add those amount into a Datagrid field
named "Gross". I can't get it to work correctly. I was trying to modify my
statement for the regular hours to do it.
fldRate is the pay rate, fldGross is gross pay and fldHours are the hours.
My current statement is:
If UCase(objFlds("fldHours")) <= "40" Then
objFlds("fldGross") = Round(objFlds("fldHours") *
objFlds("fldRate"), 2) ' normal work hours
Else
objFlds("fldGross") = Round(objFlds("fldHours") * objFlds("fldRate")
+ _ ' overtime hours
objFlds("fldHours") - 40 *
objFlds("fldRate") * 1.5, 2)
End If
Anyone have advice?