# Thread: Function to calculate revenue

1. ## 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?  Reply With Quote

2. ## 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

dTempRevenue = dCosts + (dRevenue * dTargetOverhead / 100) + (dRevenue * dNetMargin / 100)

dAdjust = (dTempRevenue - dRevenue) / 2

boolExit = True
End If

If boolExit = False Then
End If

Return dRevenue

End Function```  Reply With Quote

#### Posting Permissions

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