473,386 Members | 1,606 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

VB 6 statement question

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?
Jul 17 '05 #1
4 3475
Could you please explain, in some detail, the structure etc. of the variable 'objFlds'.

Rob.
"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?
Jul 17 '05 #2
Not sure about your objects and stuff but in pseudo code try:

Gross = Hrs * PayRate
If Hrs > 40 Then
Gross = Gross + (Hrs - 40) * PayRate * .5
End If

This will give you the correct ammount for gross.
Hope this helps :)
"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?

Jul 17 '05 #3
>>>> 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?

Jul 17 '05 #4
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?
Jul 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Greg Ofiesh | last post by:
Anyone who can help, I have two tables T1 and T2. T1 has fields K1 and F2 and T2 has fields K2 and F1. F1 is the foreign key relating to K1 and F2 is the foreign key relating to K2. My...
94
by: John Bailo | last post by:
The c# *return* statement has been bothering me the past few months. I don't like the fact that you can have different code paths in a method and have multiple return statements. To me, it...
9
by: Michael | last post by:
Hi all, I would like to get people's opinion about executing SQL statements in C# (or any other .NET language really). I used to create my SQL statement by building a string and replacing single...
7
by: Steven Bethard | last post by:
I've updated PEP 359 with a bunch of the recent suggestions. The patch is available at: http://bugs.python.org/1472459 and I've pasted the full text below. I've tried to be more explicit about...
1
by: javedna | last post by:
Can PHP help with the following as I have tried in the MYSQL Forums and cant get any help Thanks Nabz ---------------------------------------- Hi I am developing a PHP MYSQL questionnaire...
26
by: a.mil | last post by:
I am programming for code-speed, not for ansi or other nice-guy stuff and I encountered the following problem: When I have a for loop like this: b=b0; for (a=0,i=0;i<100;i++,b--) { if (b%i)...
18
by: dspfun | last post by:
Hi! The words "expression" and "statement" are often used in C99 and C- textbooks, however, I am not sure of the clear defintion of these words with respect to C. Can somebody provide a sharp...
23
by: florian.loitsch | last post by:
According to the spec Section 14 the production SourceElements:SourceElements SourceElement is evaluated as follows: 1. Evaluate SourceElements. 2. If Result(1) is an abrupt completion, return...
21
beacon
by: beacon | last post by:
Hello to everybody, I have a section on a form that has 10 questions, numbered 1-10, with 3 option buttons per question. Each of the option buttons have the same response (Yes, No, Don't know),...
10
by: JohnO | last post by:
Hi All, This question is related to iSeries V5R4 and db2. I want to implement an AFTER DELETE trigger to save the deleted rows to an archive table, I initially defined it as a FOR EACH...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...

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.