Overloading error

Burke, Brendan J 141 Reputation points
2022-03-22T22:17:12.437+00:00
  1. ' Determine the FWT.
    If radSingle.Checked Then
    GetSingleFwt(dblTaxable, dblFwt)
    Else
    dblFwt = GetMarriedFwt(dblTaxable)
    End If
  2. ' Independent Sub procedure and function.
    Private Sub GetSingleFwt(ByVal dblTaxPay As Double,
    ByRef dblFedWthTax As Double) Select Case dblTaxPay
    Case Is <= 44
    dblFedWthTax = 0
    Case Is <= 224
    dblFedWthTax = 0.1 * (dblTaxPay - 44)
    Case Is <= 774
    dblFedWthTax = 18 + 0.15 * (dblTaxPay - 244)
    Case Is <= 1812
    dblFedWthTax = 100.5 + 0.25 * (dblTaxPay - 774)
    Case Is <= 3730
    dblFedWthTax = 360 + 0.28 * (dblTaxPay - 1812)
    Case Is <= 8058
    dblFedWthTax = 897.04 + 0.33 * (dblTaxPay - 3730)
    Case Is <= 8090
    dblFedWthTax = 2325.28 + 0.35 * (dblTaxPay - 8058)
    Case Else
    dblFedWthTax = 2336.48 + 0.936 * (dblTaxPay - 8090)
    End Select
    End Sub  
    
    1. Private Function GetMarriedFwt(ByVal dblTaxPay As Double) As Double
      Dim dblFedWthTax As Double
      Select Case dblTaxPay  
          Case Is <= 166  
              dblFedWthTax = 0  
          Case Is <= 525  
              dblFedWthTax = 0.1 * (dblTaxPay - 166)  
          Case Is <= 1626  
              dblFedWthTax = 35.9 + 0.15 * (dblTaxPay - 525)  
          Case Is <= 3111  
              dblFedWthTax = 201.05 + 0.25 * (dblTaxPay - 1626)  
          Case Is <= 4654  
              dblFedWthTax = 572.3 + 0.28 * (dblTaxPay - 3111)  
          Case Is <= 8180  
              dblFedWthTax = 1004.34 + 0.33 * (dblTaxPay - 4654)  
          Case Is <= 9218  
              dblFedWthTax = 2167.92 + 0.35 * (dblTaxPay - 8180)  
          Case Else  
              dblFedWthTax = 2531.22 + 0.396 * (dblTaxPay - 9218)  
      End Select  
      Return dblFedWthTax  
      
      End Function

These Codes are overloading and that is the error but that what I am supposed to have written according to the book. The errors are in red the GetSingleFwt and the GetMarriedFwt.185784-figure-6-41.jpg185835-figure-6-45.jpg185852-figure-6-46.jpg185871-figure-6-47.jpg185769-figure-6-48.jpg

I attached these images because that is the exact part of the code where each of the errors have to do with. Figure 6-45 and 6-46 have to do with the same part as well as 6-47 and 6-48. In other words Figure 6-48 is the completed version of Figure 6-47. Figure 6-46 is the completed version of 6-45. So the main visuals to focus on are Figures 6-41, 6-46, 6-48. The errors on lines 11,34,88,90 are all related to the same issue. In other words they all have to do with each other. I have posted the code and visuals in there so it makes it clear on what parts I am talking about. The numbers at the beginning are to let you know that they are all different sub procedures that relate to the same issue.

185853-errors-line-11-and-34.jpg
185872-errors-lines-88-and-90.jpg

I hope this makes it as clear as possible.

Developer technologies | VB
{count} votes

Answer accepted by question author
  1. Jiachen Li-MSFT 34,231 Reputation points Microsoft External Staff
    2022-03-23T05:52:11.67+00:00

    Hi @Burke, Brendan J ,
    Please check if there are two identical (with the same name and parameters) methods defined in your code.
    Removing the redundant function of the same name will solve the problem.
    Best Regards.
    Jiachen Li

    ----------

    If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. LesHay 7,146 Reputation points
    2022-03-22T23:01:11.127+00:00

    Hi
    Whatever that book is, it seems to be a very old one. Some of the methods used seem to hark back to a very old style Basic code type.

    Without looking to far, Images are being ignored. If the code you actually posted for the Sub

    Private Sub GetSingleFwt(ByVal dblTaxPay As Double,
    ByRef dblFedWthTax As Double)

    then you need to re-read the book - it seems you have missed a Arithmatic operators - looks like missing some * characters maybe. (that Sub should have been a Function returning the calculated value).

    Anyway, what are the details of the book? Published when? Author? You would REALLY do well to take your studies online and uptodate.


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.