By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,512 Members | 3,847 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,512 IT Pros & Developers. It's quick & easy.

Easy "as object" question

P: n/a
I'm sure I'm just missing something here but is there a way to nest
objects inside an object or a collection that functions like an object
with properties BESIDES creating whole classes or making public
variables?

Private Sub Click()
Dim x as SomeSortOfCollection
msg box(x.Name & " " & x.Phone)
End Sub

Private Function Person() as SomeSortOfCollection
Dim Name as String= "John"
Dim Phone as String = "888-888-8888"
Person.Add(Name)
Person.Add(Phone)
End Function
What I'm not looking for:
Anything using a for each method
Using a key value like SomeObject("Name").value

Jul 29 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"sh********@yahoo.com" <sh********@yahoo.comwrote in
news:11*********************@r34g2000hsd.googlegro ups.com:
What I'm not looking for:
Anything using a for each method
Using a key value like SomeObject("Name").value
It's called a Dictionary/Hashtable :-)

Take a look at the System.Collections Namespace.
Jul 29 '07 #2

P: n/a

<sh********@yahoo.comwrote in message
news:11*********************@r34g2000hsd.googlegro ups.com...
I'm sure I'm just missing something here but is there a way to nest
objects inside an object or a collection that functions like an object
with properties BESIDES creating whole classes or making public
variables?

Private Sub Click()
Dim x as SomeSortOfCollection
msg box(x.Name & " " & x.Phone)
End Sub

Private Function Person() as SomeSortOfCollection
Dim Name as String= "John"
Dim Phone as String = "888-888-8888"
Person.Add(Name)
Person.Add(Phone)
End Function
What I'm not looking for:
Anything using a for each method
Using a key value like SomeObject("Name").value

You can use a strong type collection of objects. You can load the collection
with the objects.

You can create a function/method within the collection object to search for
object based on the value looking for and either stop on the object and
address the object or have the object returned from the collection so that
you can address its values.

You can use a for each loop in the function/method within the collection.

The one object call it NamePhone would contain property Let and Get for the
Name and Phone properties, and one NamePhone object is loaded into the
collection for each NamePhone object populated.

Jul 29 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.