Results 1 to 3 of 3

Thread: [RESOLVED] structures - Need specific item from the list

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2009
    Posts
    547

    Resolved [RESOLVED] structures - Need specific item from the list

    Hi, for example i have a structure class and obviously created a new list as so.

    My UserControl creates the new car.

    Code:
     Private _car As New List(Of Car)
    The car class had 5 members. One of which is Color

    Code:
    Public Color as string
    In my user control i have a function as so.

    Code:
        Private Function CreateCar(*removed) As Car
    
    
            Dim newCar As Car
            newCar.Price = price
            newCar. = Color
            etc........
    
            _car.Add(newCar)
    
            lstCars.Items.Add(newCar)
    
            Return newCar
    
        End Function
    I use a property to share information in the user control between usercontrol and main form

    Code:
        Public ReadOnly Property CarCollection As List(Of Car)
            Get
                Return _car
            End Get
        End Property
    Now i need main form to be able to get one of the 5 members from each added string to the list.

    (MainForm)

    Code:
            For Each line In _order.CarCollection
                MessageBox.Show(_order.CollectionCollection....stuck here)
            Next
    I need mainform to be able to gather one part of each new generated cars structure.

    bit stuck.

  2. #2
    PowerPoster
    Join Date
    Mar 2002
    Location
    UK
    Posts
    4,780

    Re: structures - Need specific item from the list

    Code:
    For Each CurrentCar As Car In CarCollection 
       MessageBox.Show(CurrentCar.Color)
    Next
    I have to guess you do not have Option Strict turned on, or you did not show your declaration of line. Ensure you have it turned on !!

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2009
    Posts
    547

    Re: structures - Need specific item from the list

    Quote Originally Posted by Grimfort View Post
    Code:
    For Each CurrentCar As Car In CarCollection 
       MessageBox.Show(CurrentCar.Color)
    Next
    I have to guess you do not have Option Strict turned on, or you did not show your declaration of line. Ensure you have it turned on !!
    I never program with out it on. I typed that in as an example. My miss take.

    works a treat.

    legend

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width