CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: calculate

  1. #1
    Guest

    calculate

    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






  2. #2
    Join Date
    Jul 1999
    Posts
    35

    Re: calculate

    What's our problem?


  3. #3
    Guest

    Re: calculate

    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.


  4. #4
    Join Date
    Jul 1999
    Posts
    35

    Re: calculate

    What do u mean by not working the code should work fine..


  5. #5
    Join Date
    Sep 1999
    Location
    Red Wing, MN USA
    Posts
    312

    Re: calculate

    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
    [email protected]
    [email protected]
    Aaron Young
    Senior Programmer Analyst (Red Wing Software)
    Certified AllExperts Expert

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured