Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Function which returns more than one value 1

Status
Not open for further replies.

NoviceNet

Programmer
May 26, 2005
15
US
How do I implement a function so that it returns more than one value? Just like Return a,b,c,d or Return array[2] or by using OUT Params?
 
Depends on what you want to return (i.e. array, dataset, etc). Sounds like you would probably want to return an array.
 
You can only return one object, but that object can be anything so it could be:

1) An array containing various strings
2) A collection containing various other objects

The limitations are endless so there is a way of returning what you want, it's just deciding on the best way for you situation.

--------------------------------------------------------------------------------------------------------------------------------------------

Need help finding an answer?

Try the search facility ( or read FAQ222-2244 on how to get better results.
 
you could do the following:

In your first class you add a function like this:

Public Function GetWhatINeed()

Dim ID As Integer = 234
Dim Name As String = "Peter"
Dim VALID AS Integer = 1

' Create Struct
Dim ExtraInfoClass As ExtraInfoClass = New ExtraInfoClass()
ExtraInfoClass.ID = ID
ExtraInfoClass.Name = Name
ExtraInfoClass.VALID = VALID
Return ExtraInfoClass
End Function

I created 3 variables to give you an idea.

After you close your class, add this:

Public Class ExtraInfoClass
Public ID As Integer
Public Name As String
Public VALID As Integer
End Class



To retrieve the values use:

GetWhatINeed.ID -> ID
GetWhatINeed.Name -> Name
GetWhatINeed.VALID -> VALID

ie. Response.Write(GetWhatINeed.Name)

Hope this helps :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top