We help IT Professionals succeed at work.

Can a function return an array?

g-spot
g-spot asked
on
Medium Priority
170 Views
Last Modified: 2010-04-24
This question leads from other questions I have asked here with regard to OOP design patterns.

If I have a "quote" class that provides a quote with prices dependant on different factors how can i call a function that would return three different prices. For example say I want to call my function that will provide quote prices for:

Vacation (Bed & Breakfast)
Vacation (Half Board)
Vacation (Full Board)

Is it possible to call the function then the function return the array of prices?
Comment
Watch Question

CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2008
Commented:
Yes, it can:

Public Function ComputePrices() As Decimal()

End Function

Bob

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
Hi Bob

Thanks again. Taking this back to my earlier question regarding objects and collections. Would I create a Price object and a prices collection that contained the various prices. This price collection would then become part of my ticket object?
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2008

Commented:
If a single ticket has multiple prices, then yes you could do it that way.

Bob

Author

Commented:
Thanks again.

You dont happen to teach VB/OOP do you? I think I need to go to VB school. ;-)
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2008

Commented:
Since true object-oriented programming hasn't been available until VB.NET, it has been a learning experience for me, too.  If you had background in C++, then object-oriented programming was a simple transition--but, I didn't have much experience with C++.

Bob

Author

Commented:
Since I only started programming anything about 9 months ago this is all a big learning experience for me. But I'm enjoying it (I think).
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2008

Commented:
Well, I have been programming for 20+ years, and the learning curve wasn't quite as steep for me.

Bob
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.