vb.net - Calculate the working hour -
i find difficult actual working hour
, minute
based on pay amount
, pay rate
per hour
.
example : working duration = (wages / pay per hour)
the following code. please help.
stractduration = cstr(math.round((dblactual / dblpayamount), 1)) dim parts string() = stractduration.split("."c) dim strhour integer = 0 dim strminutes integer = 0 if parts.length = 1 strhour = integer.parse(parts(0)) strminutes = 0 elseif parts.length = 2 strhour = integer.parse(parts(0)) strminutes = integer.parse(parts(1)) 'strroundminutes = cint(math.round(strminutes, 3)) 'strroundminutes = cint(math.truncate(strminutes / 10)) end if strcombineduration = strhour & "hr " & strminutes & "min"
keep duration number (double) , work in minutes; convert hours/minutes using .net formats:
dblminutes = math.round(60*dblactual/dblpayamount, 1) dim ts timespan = new timespan(0, dblminutes, 0) strduration = format(ts.hours, "0") & " hr " & format(ts.minutes, "0")) & " min"
Comments
Post a Comment