Results 1 to 8 of 8

Thread: [RESOLVED] [2005] help me write a class

Threaded View

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2007
    Posts
    59

    Resolved [RESOLVED] [2005] help me write a class

    I need some help with this problem. I cant figure out where im going wrong in my code.

    Create a class called clsTaxReturn. This class should have a property for income (and a private variable to store the income); negative incomes are not allowed. Add a read-only property that returns the income as a formatted string (that is, formatted as currency, $10,000 for 10000, for example). Add functions that return the income tax and insurance tax. As before:
    a. Income tax is 15% for the first $10,000 and 25% of the income in excess of $10,000 (just as in a previous question)
    b. Insurance tax is 7.75% of the first $50,000; income above $50,000 has no insurance tax. That is, an income of $25,000 would have 7.75% of all 25,000 to pay, while an income of $65,000 would only pay 7.75% of 50,000, not 7.75% of 65,000.
    Write a program to test this class.


    Here is what I have for my code.
    please help

    VB Code:
    1. Public Class clsTaxReturn
    2.  
    3.     Private decIncomeValue As Decimal
    4.     Private Value As Decimal
    5.  
    6.     Public Event DataError(ByVal sErrorMsg As String)
    7.  
    8.     Public Sub ComputeTax(ByRef decIncomeValue As Decimal, ByRef decIncomeTax As Decimal, ByRef decInsurance As Decimal)
    9.  
    10.        
    11.  
    12.         If decIncomeValue <= 10000 Then
    13.  
    14.             decIncomeTax = decIncomeValue * 0.15
    15.  
    16.         Else
    17.  
    18.             decIncomeTax = decIncomeValue * 0.25
    19.  
    20.         End If
    21.  
    22.         If decIncomeValue <= 50000 Then
    23.  
    24.             decInsurance = decIncomeValue * 0.0775
    25.  
    26.         Else
    27.  
    28.             decInsurance = 0
    29.  
    30.         End If
    31.     End Sub
    32.  
    33.     Public Property Income() As Decimal
    34.         Get
    35.             Return decIncomeValue
    36.         End Get
    37.         Set(ByVal value As Decimal)
    38.             If value >= 0 Then
    39.                 decIncomeValue = value
    40.             Else
    41.                 RaiseEvent DataError("Income cannot be negative.")
    42.             End If
    43.         End Set
    44.     End Property
    45.  
    46.     ReadOnly Property Currency() As String
    47.         Get
    48.             Return (Format(decIncomeValue, "$##,###"))
    49.         End Get
    50.     End Property
    51.  
    52.     Private Sub clsTaxReturn_DataError(ByVal sErrorMsg As String) Handles Me.DataError
    53.  
    54.     End Sub
    55. End Class
    56. Imports MyClasses
    57. Public Class Form1
    58.     Dim WithEvents Amount As New clsTaxReturn
    59.  
    60.     Private Sub Amount_dataError(ByVal sErrorMsg As String)
    61.         MessageBox.Show(sErrorMsg, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Warning)
    62.     End Sub
    63. Amount.decIncomeValue = IncomeValue.text
    64. lblInsurance.text = Amount.decInsurance
    65. lblIncome.text = Amount.decIncome
    66.  
    67. End Class
    Last edited by bhs00; Jan 8th, 2007 at 04:33 PM. Reason: no title

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