[RESOLVED] [2005] Identifying a function with multiple returns
Lets say I have a function like the simple one I have posted below. When I call the function is there a way to call it specifically depending on which variable is given?
Code:
Function CalcMeals() As Decimal
'Submit Var values to be used in the function
decDays = CDec(cboDays.SelectedItem().ToString)
decMeals = CDec(txtMeals.Text.ToString) * decDays
decMealA = CDec(conMEALS * decDays)
decMealCost = CDec(decMeals - decMealA)
decMealSaved = CDec(decMealA - decMeals)
'Determine whether to return what is owed or what is
'reimbursed.
If decMeals > decMealA Then
Return decMealCost
ElseIf decMeals < decMealA Then
Return decMealSaved
End If
End Function
I can't really lay out what I mean, best way to say is that I want to direct the amount into different areas of the form depending on what variable is returned to me. If decMealSaved is returned I want it to be added in what is exempt and if decMealCost is returned then I want it to be added in what is owed to the company. I hope I'm getting my point across...
Thanks if you can help.:eek2:
Re: [2005] Identifying a function with multiple returns
That's a bit silly. Those two values are always going to have the same magnitude but a different sign. Just create one value and return it. If it's greater than zero then it means one thing and if its less than zero then it means the other.
Re: [2005] Identifying a function with multiple returns
I am aware of that and it is easy to assume anything is silly when you have a firm grasp on what you are doing. I, on the other hand, am learning so what is silly to you could be a major dilemma to me.