-
code for calculating work week
I am teaching myself VB 6.0 on this project I need to write the correct code
for hours worked assuming a 8hr day, and assuming a 40hr week. When the user
enters the number 70, the application will display 1week, 3days, and 6hrs?
Can you help me to write the correct code I have been unsuccessful. Thanks
for your help
-
Re: code for calculating work week
"Greg Meghoo" <gaameghoo@msn.com> wrote:
>
>I am teaching myself VB 6.0 on this project I need to write the correct
code
>for hours worked assuming a 8hr day, and assuming a 40hr week. When the
user
>enters the number 70, the application will display 1week, 3days, and 6hrs?
>Can you help me to write the correct code I have been unsuccessful. Thanks
>for your help
This 2-minute code works as you want...
Public Function Elapsed(ByVal Total As Long)
Dim Wek As Long
Dim Day As Long
Dim Hrs As Long
Dim Rmn As Long
Rmn = Total
If Total > 40 Then
Wek = Int(Total / 40)
Rmn = Total - (Wek * 40)
End If
Total = Rmn
If Total > 8 Then
Day = Int(Total / 8)
Rmn = Total - (Day * 8)
End If
Hrs = Rmn
MsgBox "Weeks " & Trim(CStr(Wek)) & vbCrLf & _
"Days " & Trim(CStr(Day)) & vbCrLf & _
"Hours " & Trim(CStr(Hrs))
End Function
-
Re: code for calculating work week
"Aleksandr" <aca@mailops.com> wrote:
>Still have trouble with the code I sent an attachment to your email
>"Greg Meghoo" <gaameghoo@msn.com> wrote:
>>
>>I am teaching myself VB 6.0 on this project I need to write the correct
>code
>>for hours worked assuming a 8hr day, and assuming a 40hr week. When the
>user
>>enters the number 70, the application will display 1week, 3days, and 6hrs?
>>Can you help me to write the correct code I have been unsuccessful. Thanks
>>for your help
>
>This 2-minute code works as you want...
>
>Public Function Elapsed(ByVal Total As Long)
> Dim Wek As Long
> Dim Day As Long
> Dim Hrs As Long
> Dim Rmn As Long
>
> Rmn = Total
> If Total > 40 Then
> Wek = Int(Total / 40)
> Rmn = Total - (Wek * 40)
> End If
>
> Total = Rmn
> If Total > 8 Then
> Day = Int(Total / 8)
> Rmn = Total - (Day * 8)
> End If
>
> Hrs = Rmn
>
> MsgBox "Weeks " & Trim(CStr(Wek)) & vbCrLf & _
> "Days " & Trim(CStr(Day)) & vbCrLf & _
> "Hours " & Trim(CStr(Hrs))
>End Function
>
-
Re: code for calculating work week
Try Mod and \ function
i=70
Print i \ 40 'weeks
Print (i Mod 40) \ 8 'days
Print ((i Mod 40) Mod 8) 'remaining hrs
Greg Meghoo <gaameghoo@msn.com> wrote in message
news:39dcdf5d$1@news.devx.com...
>
> I am teaching myself VB 6.0 on this project I need to write the correct
code
> for hours worked assuming a 8hr day, and assuming a 40hr week. When the
user
> enters the number 70, the application will display 1week, 3days, and 6hrs?
> Can you help me to write the correct code I have been unsuccessful. Thanks
> for your help
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
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks