MayDay! How return array of objects from a function?

Author Message
AdmiralGanja

  • Total Posts : 6
  • Scores: 0
  • Reward points : 0
  • Joined: 3/11/2007
  • Status: offline
MayDay! How return array of objects from a function? Monday, April 16, 2007 8:47 PM (permalink)
0
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 on Tuesday, April 17, 2007 2:05 AM>
 
#1
    AdmiralGanja

    • Total Posts : 6
    • Scores: 0
    • Reward points : 0
    • Joined: 3/11/2007
    • Status: offline
    RE: MayDay! How return array of objects from a function? Tuesday, April 17, 2007 2:05 AM (permalink)
    0
    I think I solved it some how with like:
    set getCars = CarObject.Item(0)
     
    Thanks anyhow
     
    #2

      Online Bookmarks Sharing: Share/Bookmark

      Jump to:

      Current active users

      There are 0 members and 1 guests.

      Icon Legend and Permission

      • 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
      • Read Message
      • Post New Thread
      • Reply to message
      • Post New Poll
      • Submit Vote
      • Post reward post
      • Delete my own posts
      • Delete my own threads
      • Rate post

      2000-2012 ASPPlayground.NET Forum Version 3.9