Easy "as object" question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • shawncraig@yahoo.com

    #1

    Easy "as object" question

    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 SomeSortOfColle ction
    msg box(x.Name & " " & x.Phone)
    End Sub

    Private Function Person() as SomeSortOfColle ction
    Dim Name as String= "John"
    Dim Phone as String = "888-888-8888"
    Person.Add(Name )
    Person.Add(Phon e)
    End Function


    What I'm not looking for:
    Anything using a for each method
    Using a key value like SomeObject("Nam e").value

  • Spam Catcher

    #2
    Re: Easy "as object" question

    "shawncraig@yah oo.com" <shawncraig@yah oo.comwrote in
    news:1185678132 .543341.23630@r 34g2000hsd.goog legroups.com:
    What I'm not looking for:
    Anything using a for each method
    Using a key value like SomeObject("Nam e").value
    It's called a Dictionary/Hashtable :-)

    Take a look at the System.Collecti ons Namespace.

    Comment

    • Mr. Arnold

      #3
      Re: Easy &quot;as object&quot; question


      <shawncraig@yah oo.comwrote in message
      news:1185678132 .543341.23630@r 34g2000hsd.goog legroups.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 SomeSortOfColle ction
      msg box(x.Name & " " & x.Phone)
      End Sub
      >
      Private Function Person() as SomeSortOfColle ction
      Dim Name as String= "John"
      Dim Phone as String = "888-888-8888"
      Person.Add(Name )
      Person.Add(Phon e)
      End Function
      >
      >
      What I'm not looking for:
      Anything using a for each method
      Using a key value like SomeObject("Nam e").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.

      Comment

      Working...