Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3931832
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T23:23:25+00:00 2026-05-19T23:23:25+00:00

This is a simplified version of a class that I have in my project.

  • 0

This is a simplified version of a class that I have in my project. Since the Bonus is figured the exact same way in each function I want to remove the obvious code duplication that appears here and make the three different functions into one. However I am not sure how to provide the argument that this new function would require.

For instance I am currently just passing the argument like this from code

lblVolumeBonus.Content = TestClass.VolumeBonusAmountStore(bonus).

I think I have to basically turn this logic around and call it with something like

lblVolumeBonus.Content = TestClass.VolumeBonusAmountStore(BonusTrackerBO.StoreBonus)

but I am not sure of the correct syntax or whether I am on the right track at all.

Can someone help get me in the right direction?

Public Class TestClass
Public Shared Function StoreBonus(ByVal bonus As BonusTrackerBO.StoreBonus) As Double

    Dim myBonus As Double = bonus.TicketAmount
    Return myBonus * 5

End Function

Public Shared Function DistrictBonus(ByVal bonus As BonusTrackerBO.DistrictBonus) As Double

    Dim myBonus As Double = bonus.TicketAmount
    Return myBonus * 5

End Function

Public Shared Function CompanyBonus(ByVal bonus As BonusTrackerBO.CompanyBonus) As Double

    Dim myBonus As Double = bonus.TicketAmount
    Return myBonus * 5

End Function
End Class

Edit: It may not make a difference but I should have made clear that there are other factors in the equation (I was just trying to keep it simple). So is the answer the same when there are other callbacks to the bonus like bonus.MaximumAmount, bonus.MinimumAmount? There are 5 callbacks to the bonus object and the amounts are different depending on whether it is a Store, District or Company asking.

  • 1 1 Answer
  • 3 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T23:23:26+00:00Added an answer on May 19, 2026 at 11:23 pm

    How about:

    Public Shared Function GetBonus(ByVal bonus as Double) As Double
        Return bonus * 5
    End Function
    

    Where bonus is bonus.TicketAmount. Or if They all inherit from a base class like BaseBonusClass.

    Public Shared Function GetBonus(ByVal bonus as BaseBonusClass) As Double
        Return bonus.TicketAmount * 5
    End Function
    

    Edit: or try generics

    Public Shared Function GetBonus(Of T As BaseBonusClass)(ByVal bonus as T) As Double
        Return bonus.TicketAmount * 5
    End Function
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a data structure that looks like this (simplified version) class A(models.Model): a
This is a simplified version of a class that I have in php: class
I have class B that has class A, this is simplified version of class
Here is very simplified version of code that i have: class PrintJob : IEntity
I have a class that represents an external physical measuring device. The simplified version
This is a simplified version of my question earlier today since I didn't get
This is some code that is behaving peculiarly. This is a simplified version of
This is a simplified partial version of my code to demonstrate the issue: function
Suppose I have class Function , whose instances are callables that take one argument.
I have the following C++ code (simplified version): class Shape { bool isCircle =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.