Results 1 to 2 of 2

Thread: Function to calculate revenue

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Mar 2004
    Location
    Orlando, FL
    Posts
    1,618

    Function to calculate revenue

    Am looking for some thoughts on how to do this. I wrote a project management application that has a financials section that has all the basic financials of a project. Project revenue, labor costs, expenses, taxes, and then overhead as a percentage of revenue.

    I now have been asked to write a tool that takes these values and determines what the project revenue should be. The issue is that one of the variable of revenue is an overhead cost that is a percentage of that same revenue.

    The possible solution I came up with to write some kind of recursive function that performs multiple iterations that keep getting closer to the correct value, like for example start with an assumed revenue of all costs plus say 20%, and then use the targeted overhead percent against that value to get close to the correct revenue then keep looping and correcting the revenue by x amount every iteration until finding the correct amount.

    Any thoughts on if this is a bad way to approach this, or ideas on a better way to do this?
    Sean

    Some days when I think about the next 30 years or so of my life I am going to spend writing code, I happily contemplate stepping off a curb in front of a fast moving bus.

  2. #2

    Thread Starter
    Frenzied Member
    Join Date
    Mar 2004
    Location
    Orlando, FL
    Posts
    1,618

    Re: Function to calculate revenue

    If anybody had any interest this seems to have done the trick:

    Code:
        Public Function CalculateRevenue(ByRef dRevenue As Decimal, ByVal dCosts As Decimal, ByVal dTargetOverhead As Decimal, ByVal dNetMargin As Decimal, ByVal dAdjust As Decimal) As Decimal
            Dim dTempRevenue As Decimal = 0
            Dim boolExit As Boolean = False
    
            dRevenue += dAdjust
    
            dTempRevenue = dCosts + (dRevenue * dTargetOverhead / 100) + (dRevenue * dNetMargin / 100)
    
            dAdjust = (dTempRevenue - dRevenue) / 2
    
            If (Math.Abs(dAdjust) < 0.01) Then
                boolExit = True
            End If
    
            If boolExit = False Then
                CalculateRevenue(dRevenue, dCosts, dTargetOverhead, dNetMargin, dAdjust)
            End If
    
            Return dRevenue
    
        End Function
    Sean

    Some days when I think about the next 30 years or so of my life I am going to spend writing code, I happily contemplate stepping off a curb in front of a fast moving bus.

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