Computing.Net > Forums > Programming > Visual Basic 6

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Visual Basic 6

Reply to Message Icon

Name: cooperma
Date: December 15, 2005 at 14:25:05 Pacific
OS: XP
CPU/Ram: 1.6/1gb
Comment:

I am using VB6 to create a program for a gross pay calculator. I am trying to find code so it will work. right now i have :

BasePay = Rate * Hours
OverTimePay = ((Hours.Text - 40) * 1.5) * Rate
Gross.Text = (BasePay + OverTimePay)

However, it seems that, no matter what, it always subtracts 40 hrs, and multiplies it by 1.5. This is only the second program i have created. NEED HELP PLEASE!



Sponsored Link
Ads by Google

Response Number 1
Name: StuartS
Date: December 15, 2005 at 14:49:31 Pacific
Reply:

The way you have written the code that what it will do.

Functions inside parentheses are evaluated first working outward so that functions with without parentheses are evaluated last.

So the way you have written the code, 40 is subtracted from hours. The result of that is multiplied by 1.5. The result of that is then multiplied by rate.

What is it you want it to do?

Stuart


0

Response Number 2
Name: cooperma
Date: December 15, 2005 at 14:53:40 Pacific
Reply:

Thanks for the quick response. I ended up using a if else decision thingy. I put

If Hours.Text > 40 Then
Gross.Text = 40 * Rate.Text + (Hours.Text - 40) * 1.5 * Rate.Text
Else

Gross.Text = Hours.Text * Rate.Text

End If

This gave me the proper result.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


wininet.dll API for VB6 H... Batch: file search, get d...



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Visual Basic 6

List Databses is Visual Basic 6 www.computing.net/answers/programming/list-databses-is-visual-basic-6/15612.html

DirectX 8.1 SDK w/ Visual Basic 6 www.computing.net/answers/programming/directx-81-sdk-w-visual-basic-6/249.html

visual basic 6 www.computing.net/answers/programming/visual-basic-6/11343.html