(calc) Subtraction code with VB6

Thread Solved
Reply

Join Date: Nov 2008
Posts: 13
Reputation: BigSeckC is an unknown quantity at this point 
Solved Threads: 0
BigSeckC's Avatar
BigSeckC BigSeckC is offline Offline
Newbie Poster

(calc) Subtraction code with VB6

 
0
  #1
Nov 16th, 2008
Hey all,

I apologize now for being a Noob. I'm using a Tutorial to learn VB6 (for starters) and everything was going great until just now... The assignment is to create a Weekly Payroll. I have managed to figure out how to make the standard calc ( Hrs worked * Rate ) and display properly, however, that's when my legs get knocked out from under me

I'm not entirely sure how to subtract the deductions. I tried searching but couldn't find a similar situation. Below is my working code, albeit probably OC'd... over-coded.

*scratches head... how do I subtract? I 'thought' it would be:

If opta.Value = True Then _
intgsal = (txthrs.Text * 10) _
And intnet = (txthrs.Text * 10 - txtded.Text) <-- txtded.Text being my Deductions

txtgsal.Text = intgsal
txtnet.Text = intnet

...I was sooooo wrong... more errors than a little bit!


My 'working' code is below - any help would be appreciated! Also, if there are shortcuts (i.e., functions) that I could use in the future - I would like to know that as well!

Thanks again!



  1. 'setting up Integers for
  2. 'calculations
  3.  
  4. Option Explicit
  5. Dim intgsal As Integer 'Gross Salary
  6. Dim intnet As Integer 'Net Salary
  7. Dim inthrs As Integer 'Hours Worked
  8. Dim intded As Integer 'Deductions
  9.  
  10. 'setting text box values to
  11. '"blank" and "0"
  12.  
  13. Private Sub Form_Load()
  14. txtname.Text = " "
  15. txthrs.Text = "0.00"
  16. txtded.Text = "0.00"
  17. txtgsal.Text = "0.00"
  18. txtnet.Text = "0.00"
  19.  
  20. End Sub
  21.  
  22. 'coding Confirm to calculate
  23.  
  24. Private Sub cmdconfirm_Click()
  25.  
  26. If opta.Value = True Then _
  27. intgsal = (txthrs.Text * 10)
  28.  
  29. txtgsal.Text = intgsal
  30.  
  31. End Sub
I am who I am...I do what I do
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 13
Reputation: BigSeckC is an unknown quantity at this point 
Solved Threads: 0
BigSeckC's Avatar
BigSeckC BigSeckC is offline Offline
Newbie Poster

Re: (calc) Subtraction code with VB6

 
0
  #2
Nov 16th, 2008
Got it!!! Figured out the Code I needed... at least for now...

  1. 'coding Confirm to calculate
  2.  
  3. Private Sub cmdconfirm_Click()
  4.  
  5. If opta.Value = True Then
  6. intgsal = (txthrs.Text * 10)
  7. txtgsal.Text = intgsal
  8. intnet = (intgsal - txtded.Text)
  9. txtnet.Text = intnet
  10. End If
  11. End Sub
I am who I am...I do what I do
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Other Threads in the Visual Basic 4 / 5 / 6 Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC