Click to See Complete Forum and Search --> : calculate


October 8th, 1999, 10:24 AM
I am taking the value of a number and multiplying it by .20. Then the I am trying to take the new value and subtract t from the original number. What am I doing wrong here?

option Explicit

private Sub cmdCalculate_Click()
Dim GrossSalary as Double
Dim GrossSalaryCalc as Double
Dim TaxLoss as Double
Dim NetSalary as Double
Dim YearlySalary as Double

GrossSalary = Val(txtGrossSalary.Text)
'GrossSalaryCalc = GrossSalary - TaxLoss
TaxLoss = Val(lblTaxLoss.Caption)
'NetSalary = Val(lblNetSalary.Caption)
'YearlySalary = Val(lblYearlySalary.Caption)

lblTaxLoss.Caption = GrossSalary * 0.2
lblNetSalary.Caption = GrossSalary - TaxLoss
lblYearlySalary.Caption = GrossSalary * 24

End Sub

private Sub cmdClear_Click()
txtGrossSalary.Text = ""
lblTaxLoss.Caption = ""
lblNetSalary.Caption = ""
lblYearlySalary.Caption = ""
txtGrossSalary.SetFocus

End Sub

private Sub cmdExit_Click()
End

End Sub

private Sub cmdPrint_Click()
PrintForm

End Sub

wolfen_76
October 8th, 1999, 10:33 AM
What's our problem?

October 8th, 1999, 10:56 AM
Well, I basicly have this:
Gross:1000
Tax Loss:200
Net:1000
The tax should get subtracted from the gross to get the net but it is not working.

wolfen_76
October 8th, 1999, 11:21 AM
What do u mean by not working the code should work fine..

Aaron Young
October 8th, 1999, 03:51 PM
You are getting the Value for TaxLoss before you have calculated it, try this:

private Sub cmdCalculate_Click()
Dim GrossSalary as Double
Dim GrossSalaryCalc as Double
Dim TaxLoss as Double
Dim NetSalary as Double
Dim YearlySalary as Double
GrossSalary = Val(txtGrossSalary.Text)
lblTaxLoss.Caption = GrossSalary * 0.2
TaxLoss = Val(lblTaxLoss.Caption)
lblNetSalary.Caption = GrossSalary - TaxLoss
lblYearlySalary.Caption = GrossSalary * 24
End Sub




Aaron Young
Analyst Programmer
adyoung@win.bright.net
aarony@redwingsoftware.com