| | |
(calc) Subtraction code with VB6
Thread Solved
![]() |
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!
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!
vb Syntax (Toggle Plain Text)
'setting up Integers for 'calculations Option Explicit Dim intgsal As Integer 'Gross Salary Dim intnet As Integer 'Net Salary Dim inthrs As Integer 'Hours Worked Dim intded As Integer 'Deductions 'setting text box values to '"blank" and "0" Private Sub Form_Load() txtname.Text = " " txthrs.Text = "0.00" txtded.Text = "0.00" txtgsal.Text = "0.00" txtnet.Text = "0.00" End Sub 'coding Confirm to calculate Private Sub cmdconfirm_Click() If opta.Value = True Then _ intgsal = (txthrs.Text * 10) txtgsal.Text = intgsal End Sub
I am who I am...I do what I do
Got it!!! Figured out the Code I needed... at least for now...
vb Syntax (Toggle Plain Text)
'coding Confirm to calculate Private Sub cmdconfirm_Click() If opta.Value = True Then intgsal = (txthrs.Text * 10) txtgsal.Text = intgsal intnet = (intgsal - txtded.Text) txtnet.Text = intnet End If End Sub
I am who I am...I do what I do
![]() |
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: Macro Excel and serial port
- Next Thread: Remove the "x" in the window at runtime
| Thread Tools | Search this Thread |
* 6 2007 access activex add age basic beginner birth bmp calculator cd cells.find click client code college connection connectionproblemusingvb6usingoledb creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit excel excelmacro file filename form header iamthwee image inboxinvb internetfiledownload listbox listview liveperson login looping microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading remotesqlserverdatabase report save search sendbyte sites sql sql2008 sqlserver subroutine tags time urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web windows





