|
-
Mar 31st, 2007, 12:38 AM
#1
Thread Starter
Addicted Member
[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.
Abrium
Asking the beginners questions so you don't have to!
If by chance hell actually froze over and I some how helped you... Please rate.
-
Mar 31st, 2007, 02:56 AM
#2
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.
-
Apr 1st, 2007, 03:59 AM
#3
Thread Starter
Addicted Member
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.
Abrium
Asking the beginners questions so you don't have to!
If by chance hell actually froze over and I some how helped you... Please rate.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|