I won't tackle classes right now, but here are a couple more methods:

4. User-Defined Data Types

5. Collections

 

Here's a user-defined data type example:

Type ContactInfo

    Name As String

    Address As String

End Type

 

Function WhoAmi() As ContactInfo

With WhoAmi

    .Name = "Samwise Gamgee"

    .Address = "Hobbiton, The Shire, Arthedain, Eriador, Middle Earth" ' (I
think)

End With

End Function

 

Sub Test_WhoAmi()

Dim My As ContactInfo

My = WhoAmI

MsgBox "I Am " & My.Name & " and my address is " & My.Address & ".",
vbInformation

End Sub

 

Asa

 

From: excel-macros@googlegroups.com [mailto:excel-macros@googlegroups.com]
On Behalf Of hanumant shinde
Sent: Wednesday, December 21, 2011 1:08 PM
To: Excel Group
Subject: $$Excel-Macros$$ Return More than 1 value from Function

 

Hi,

 

How can we return more than 1 value from 1 function.

 

1. using array

2. using By Ref for the values.

3. Create a class with the properties you require to return and then return
the object of that class from the function.

 

i understand 1st two methods. can somebody explain the 3rd and how to
achieve this with the proper example.

i have never created class so i dont know ANYTHING about it.

-- 
FORUM RULES (934+ members already BANNED for violation)
 
1) Use concise, accurate thread titles. Poor thread titles, like Please
Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will
not get quick attention or may not be answered.
 
2) Don't post a question in the thread of another member.
 
3) Don't post questions regarding breaking or bypassing any security
measure.
 
4) Acknowledge the responses you receive, good or bad.
 
5) Cross-promotion of, or links to, forums competitive to this forum in
signatures are prohibited. 
 
NOTE : Don't ever post personal or confidential data in a workbook. Forum
owners and members are not responsible for any loss.
 
----------------------------------------------------------------------------
--------------------------
To post to this group, send email to excel-macros@googlegroups.com

-- 
FORUM RULES (934+ members already BANNED for violation)

1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
quick attention or may not be answered.

2) Don't post a question in the thread of another member.

3) Don't post questions regarding breaking or bypassing any security measure.

4) Acknowledge the responses you receive, good or bad.

5)  Cross-promotion of, or links to, forums competitive to this forum in 
signatures are prohibited. 

NOTE  : Don't ever post personal or confidential data in a workbook. Forum 
owners and members are not responsible for any loss.

------------------------------------------------------------------------------------------------------
To post to this group, send email to excel-macros@googlegroups.com

Reply via email to