Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


MayDay! How return array of objects from a function?

 
Logged in as: Guest
arrSession:exec spGetSession 2,3,45969
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> ASP >> MayDay! How return array of objects from a function?
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 MayDay! How return array of objects from a function? - 4/16/2007 7:47:26 PM   
  AdmiralGanja

 

Posts: 6
Score: 0
Joined: 3/11/2007
Status: offline
SOLVED
Please Help!
 
I need to return a dictionary or array of objects
from a function but it does not work.

The below works fine if i type Response.Write(getCars()).
If I need to return the whole list by changing:
 
From:  getCars = CarObject.Item(0).color
To:  getCars = CarObject.Item(0)
 
it does not work with Response.Write(getCars().color).
 
Why is this? I need to be able to return a dictionary with objects or at least an Array with objects.
 
Thanks in advance!
/Jesper Wilfing

*** FUNCTION TO RETURN MY DICTIONARY OR ARRAY OF OBJECTS
Public Function getCars()
 
Dim CarObject1
Dim CarObject2
 
Set CarObject1 = new Car
Set CarObject2 = new Car
 
Dim CarObject
Set CarObject = CreateObject("Scripting.Dictionary")

CarObject1.color =
"red"

CarObject1.brand =
"volvo"

CarObject.Add 0, CarObject1


CarObject2.color =
"purple"

CarObject2.brand =
"saab"

CarObject.Add 1, CarObject2


getCars = CarObject.Item(0).color

End
Function



Response.Write(getCars())


'*** CAR CLASS ***
Class
Car
  Private strColor
  Private strBrand
 

Public Property Let color(ByVal value)
strColor = value
End Property

 
Public Property Get color
color = strColor
End Property


 
Public Property Let brand(ByVal value)
strBrand = value
End Property

 
Public Property Get brand
brand = strBrand
End Property


End
class


< Message edited by AdmiralGanja -- 4/17/2007 1:05:38 AM >
 
 
Post #: 1
 
 RE: MayDay! How return array of objects from a function? - 4/17/2007 1:05:03 AM   
  AdmiralGanja

 

Posts: 6
Score: 0
Joined: 3/11/2007
Status: offline
I think I solved it some how with like:
set getCars = CarObject.Item(0)
 
Thanks anyhow

(in reply to AdmiralGanja)
 
 
Post #: 2
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> ASP >> MayDay! How return array of objects from a function? Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts