473,659 Members | 3,117 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

calculate amount of hours worked

153 New Member
Hi,

I am designing a project for my friend as I am just a week old baby to vb and want to implement what I've learnt so far.

She wants to be able to put start time, end time and lunch for each day and then calculate amount of hours worked. So far I have designed form and added code to calculate textbox inputs, (which works!).

However, I didn't think of this at beginning. Say I put .30 for lunch, when I get total hours worked the answer would be .70 as it's taking .30 away from 1. (Sounds obvious now!) I want it to calculate as minutes in an hour. Is there a way of telling the project half nine is 9.30 instead of having to input 9.50 ?

Any comments would be appreciated
Expand|Select|Wrap|Line Numbers
  1. Dim SunTotal As Variant
  2. Dim MonTotal As Variant
  3. Dim TuesTotal As Variant
  4. Dim WedsTotal As Variant
  5. Dim Thurstotal As Variant
  6. Dim FriTotal As Variant
  7. Dim SatTotal As Variant
  8.  
  9. Dim HoursTotal As Variant
  10.  
  11. Dim valsunend As Variant
  12. Dim valmonend As Variant
  13. Dim valtuesend As Variant
  14. Dim valwedsend As Variant
  15. Dim valthursend As Variant
  16. Dim valfriend As Variant
  17. Dim valsatend As Variant
  18.  
  19. Dim valsunstart As Variant
  20. Dim valmonstart As Variant
  21. Dim valtuesstart As Variant
  22. Dim valwedsstart As Variant
  23. Dim valthursstart As Variant
  24. Dim valfristart As Variant
  25. Dim valsatstart As Variant
  26.  
  27. Dim valsunlunch As Variant
  28. Dim valmonlunch As Variant
  29. Dim valtueslunch As Variant
  30. Dim valwedslunch As Variant
  31. Dim valthurslunch As Variant
  32. Dim valfrilunch As Variant
  33. Dim valsatlunch As Variant
  34.  
  35. Private Sub CmdCalculate_Click()
  36. valsunend = Val(TxtSunEnd.Text)
  37. valmonend = Val(TxtMonEnd.Text)
  38. valtuesend = Val(TxtTuesEnd.Text)
  39. valwedsend = Val(TxtWedsEnd.Text)
  40. valthursend = Val(TxtThursEnd.Text)
  41. valfriend = Val(TxtFriEnd.Text)
  42. valsatend = Val(TxtSatEnd.Text)
  43.  
  44. valsunstart = Val(TxtSunStart.Text)
  45. valmonstart = Val(TxtMonStart.Text)
  46. valtuesstart = Val(TxtTuesStart.Text)
  47. valwedsstart = Val(TxtWedsStart.Text)
  48. valthursstart = Val(TxtThursStart.Text)
  49. valfristart = Val(TxtFriStart.Text)
  50. valsatstart = Val(TxtSatStart.Text)
  51.  
  52. valsunlunch = Val(TxtSunLunch.Text)
  53. valmonlunch = Val(TxtMonLunch.Text)
  54. valtueslunch = Val(TxtTuesLunch.Text)
  55. valwedslunch = Val(TxtWedsLunch.Text)
  56. valthurslunch = Val(TxtThursLunch.Text)
  57. valfrilunch = Val(TxtFriLunch.Text)
  58. valsatlunch = Val(TxtSatLunch.Text)
  59.  
  60. SunTotal = valsunend - valsunstart - valsunlunch
  61. MonTotal = valmonend - valmonstart - valmonlunch
  62. TuesTotal = valtuesend - valtuesstart - valtueslunch
  63. WedsTotal = valwedsend - valwedsstart - valwedslunch
  64. Thurstotal = valthursend - valthursstart - valthurslunch
  65. FriTotal = valfriend - valfristart - valfrilunch
  66. SatTotal = valsatend - valsatstart - valsatlunch
  67.  
  68. HoursTotal = SunTotal + MonTotal + TuesTotal + WedsTotal + Thurstotal + FriTotal + SatTotal
  69. LblHours.Caption = HoursTotal
  70. End Sub
Nov 30 '07 #1
9 2472
debasisdas
8,127 Recognized Expert Expert
Instead of using textbox try to use DtPicker for time entry

set the format to dtptime.

why u have declared all the variant variables ?
Nov 30 '07 #2
lotus18
866 Contributor
Hi brendanmcdonagh

Or you can create a combobox and list down all the time that you wanted : )

Rey Sean
Nov 30 '07 #3
brendanmcdonagh
153 New Member
Set as Variants as new to vb so will look up what they really need to be in a bit - Thanks for that.

Combo not really an option as different time options are a lot.

DtPicker - need to look that up -

So grateful for everyone helping thank you
Nov 30 '07 #4
brendanmcdonagh
153 New Member
Can anyone point me in right direction as to how to get to dtpicker, i've searched but no instructions how to actually get to it. I'll do the rest from there I promise!
Nov 30 '07 #5
lotus18
866 Contributor
Can anyone point me in right direction as to how to get to dtpicker, i've searched but no instructions how to actually get to it. I'll do the rest from there I promise!
From the toolbar, right-click then select Component... From the Control tab, select MS Windows Common-2 6.0

Rey Sean
Nov 30 '07 #6
brendanmcdonagh
153 New Member
thank you so much - again!!
Nov 30 '07 #7
lotus18
866 Contributor
thank you so much - again!!
You're much welcome. Good Luck : )

Rey Sean
Nov 30 '07 #8
hariharanmca
1,977 Top Contributor
Why you are using variant type (variant data type will convert data type itself when we assign value), It seems total of hours. Better use integer type.

Use a combo box for sun–to–sat day and three DTPDateTimepick er so it will speed up your form load and save more space in form.
Nov 30 '07 #9
lotus18
866 Contributor
Why you are using variant type (variant data type will convert data type itself when we assign value), It seems total of hours. Better use integer type.

Use a combo box for sun–to–sat day and three DTPDateTimepick er so it will speed up your form load and save more space in form.
Yes I agree, variant consumes more memory space than defining the datatype, I think : )

Rey Sean
Nov 30 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

1
13598
by: sg_s123 | last post by:
============================================================================ 02-Feb-04 03-Feb-04 Staff Staff 0800hr- 1300hr- 1700hr- 1900hr- 0800hr- 1300hr- 1700hr- 1900hr- Number Name 1200hr 1700hr 1900hr 2200hr 1200hr 1700hr 1900hr 2200hr ============================================================================ 4654 Saniff A A A C A A A C 4437 Joey B C B C B C B C 4479 Elmer C C B C C C B C
5
6511
by: cvisal | last post by:
Hi all Im working on productivity calculations (Time calculations) and need some help in coding. Database Tool:MS-Access 2003. The general operator punch-in time is 5:30 AM and the punch-out time is 2:00PM. The Break times are 1) 9:30 AM to 9:45 AM 2) 11:00AM to 11:30 AM 3) 12:30PM to 12:45 PM
6
7461
by: Programador | last post by:
I'm getting this error when running this program: Cannot calculate rate using the arguments provided Module Module1 Sub Main() Rate(360, -694.44444444444446, 244274.69178082192) End Sub
3
2426
by: Michelle Anderson | last post by:
I have an access form. In the form, it co ntains 3 fields : Type, hours, and Amount. Field "Type" is a combo box and it contains 2 values: Standard and Rush Field " Hours" is just a numeric field Field "Amount" is a currency field. What I try to do is if the user select Standard from the field "Type", the field "Amount" will be automatically populate by: 24*, else if the type is "Rush" then the Amount field will be as 26* I am not...
1
7470
by: deena22 | last post by:
hello, i'm using 'Access database' and VB 6.0. My database is named ' timesheet' and it contains a table named 'tabletimesheet'. The table contain the following fields: 'staffname, stafftype, date, projectname, projectcode and hoursworked' . On my VB 6.0 form, i have got a ' list Box' containing the 'type of staff', for example 'engineer, manager or secretary'. I have got another 'list Box' containing the 'name of projects' . Also i have...
4
2743
by: Sector 7G | last post by:
I'm working with a SQL query for a Human Resources database. Its intended purpose is to find all the paycheck records with a check date (prckhist.chkdate ) more recent than eleven days past the employee's last raise (hrpersnl.p_paydate). It then totals the hours the employee worked from those records (prdehist.units), and if the total is within 40 hours of a threshold (hrpersnl.p_jmisc3) then the employee's name and information is returned, and...
28
4377
by: DavidOwens | last post by:
hey guys i want to have a html form which users would fil in and they click display and it would be update to another form and calculations carried out e.g so just say they filled forms were it had name: , day worked mon,tues,weds,thurs,fri: ,were worked: store, hosi(put number of hours worked in each),they then submit the form, the other form is then displayed and the total number of hours calculated ideas guys??
5
2721
by: brendanmcdonagh | last post by:
Hi, I have been learning VB now for about a week and thought I was doing ok. I have already done a calculation form (not as big as this) . I have volunteered myself to help a friend input her hours per day into a form, start time, end time and lunch time. Then the form will calculate the amount of hours she has done for her. Sending results to access is not an issue yet! When I have entered the below code and tested it, it let's me input...
15
6420
by: student4lifer | last post by:
Hello, I have 2 time fields dynamically generated in format "m/d/y H:m". Could someone show me a good function to calculate the time interval difference in minutes? I played with strtotime() but but that only gave me difference in hours and only if the times were on the same day (after wrapping with date() function). TIA
0
8335
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8851
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8747
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8627
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6179
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4335
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2752
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.