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 -
Dim SunTotal As Variant
-
Dim MonTotal As Variant
-
Dim TuesTotal As Variant
-
Dim WedsTotal As Variant
-
Dim Thurstotal As Variant
-
Dim FriTotal As Variant
-
Dim SatTotal As Variant
-
-
Dim HoursTotal As Variant
-
-
Dim valsunend As Variant
-
Dim valmonend As Variant
-
Dim valtuesend As Variant
-
Dim valwedsend As Variant
-
Dim valthursend As Variant
-
Dim valfriend As Variant
-
Dim valsatend As Variant
-
-
Dim valsunstart As Variant
-
Dim valmonstart As Variant
-
Dim valtuesstart As Variant
-
Dim valwedsstart As Variant
-
Dim valthursstart As Variant
-
Dim valfristart As Variant
-
Dim valsatstart As Variant
-
-
Dim valsunlunch As Variant
-
Dim valmonlunch As Variant
-
Dim valtueslunch As Variant
-
Dim valwedslunch As Variant
-
Dim valthurslunch As Variant
-
Dim valfrilunch As Variant
-
Dim valsatlunch As Variant
-
-
Private Sub CmdCalculate_Click()
-
valsunend = Val(TxtSunEnd.Text)
-
valmonend = Val(TxtMonEnd.Text)
-
valtuesend = Val(TxtTuesEnd.Text)
-
valwedsend = Val(TxtWedsEnd.Text)
-
valthursend = Val(TxtThursEnd.Text)
-
valfriend = Val(TxtFriEnd.Text)
-
valsatend = Val(TxtSatEnd.Text)
-
-
valsunstart = Val(TxtSunStart.Text)
-
valmonstart = Val(TxtMonStart.Text)
-
valtuesstart = Val(TxtTuesStart.Text)
-
valwedsstart = Val(TxtWedsStart.Text)
-
valthursstart = Val(TxtThursStart.Text)
-
valfristart = Val(TxtFriStart.Text)
-
valsatstart = Val(TxtSatStart.Text)
-
-
valsunlunch = Val(TxtSunLunch.Text)
-
valmonlunch = Val(TxtMonLunch.Text)
-
valtueslunch = Val(TxtTuesLunch.Text)
-
valwedslunch = Val(TxtWedsLunch.Text)
-
valthurslunch = Val(TxtThursLunch.Text)
-
valfrilunch = Val(TxtFriLunch.Text)
-
valsatlunch = Val(TxtSatLunch.Text)
-
-
SunTotal = valsunend - valsunstart - valsunlunch
-
MonTotal = valmonend - valmonstart - valmonlunch
-
TuesTotal = valtuesend - valtuesstart - valtueslunch
-
WedsTotal = valwedsend - valwedsstart - valwedslunch
-
Thurstotal = valthursend - valthursstart - valthurslunch
-
FriTotal = valfriend - valfristart - valfrilunch
-
SatTotal = valsatend - valsatstart - valsatlunch
-
-
HoursTotal = SunTotal + MonTotal + TuesTotal + WedsTotal + Thurstotal + FriTotal + SatTotal
-
LblHours.Caption = HoursTotal
-
End Sub
9 2472
Instead of using textbox try to use DtPicker for time entry
set the format to dtptime.
why u have declared all the variant variables ?
Hi brendanmcdonagh
Or you can create a combobox and list down all the time that you wanted : )
Rey Sean
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
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!
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
thank you so much - again!!
thank you so much - again!!
You're much welcome. Good Luck : )
Rey Sean
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.
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
Sign in to post your reply or Sign up for a free account.
Similar topics |
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
|
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
|
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
|
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...
|
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...
| |
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...
|
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??
|
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...
|
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
|
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,...
|
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...
| |
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...
|
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...
|
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...
|
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();...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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
| |