Deleteing from a list(of t

paulthepaddy

Well-known member
Joined
Apr 9, 2011
Messages
222
Location
UK
Programming Experience
Beginner
Hey guys i am trying to 'Update' an item in a list
The idea i was try to use was going to be to remove the item then add it again. so far this is the code i have

The Classes, i tried ot colour them as best as i could, to make it easier to read :D, hope it helps
VB.NET:
[COLOR=#0000ff]Public Module [/COLOR][COLOR=#00ffff]CarListClasses[/COLOR][COLOR=#0000FF]
    Public Function [/COLOR]GetCarList()[COLOR=#0000FF] As [/COLOR][COLOR=#00ffff]CarList[/COLOR][COLOR=#0000FF]
        Dim [/COLOR][COLOR=#000000]objStreamReader[/COLOR][COLOR=#0000FF] As New [/COLOR][COLOR=#00ffff]StreamReader(Application[/COLOR][COLOR=#0000FF].[/COLOR][COLOR=#000000]StartupPath[COLOR=#0000FF] [/COLOR]&[/COLOR][COLOR=#0000FF] "\Resources\CarList.xml"[/COLOR][COLOR=#000000])[/COLOR][COLOR=#0000FF]
        Dim [/COLOR][COLOR=#000000]CarList[/COLOR][COLOR=#0000FF] As New [/COLOR][COLOR=#00ffff]CarList[/COLOR][COLOR=#0000FF]
        Dim [/COLOR][COLOR=#000000]x[/COLOR][COLOR=#0000FF] As New [/COLOR][COLOR=#00ffff]XmlSerializer[/COLOR][COLOR=#0000FF]([/COLOR][COLOR=#000000]CarList.GetType[/COLOR][COLOR=#0000FF])
        [/COLOR][COLOR=#000000]CarList[/COLOR][COLOR=#0000FF] = CType[/COLOR][COLOR=#000000](x.Deserialize(objStreamReader)[/COLOR][COLOR=#0000FF], [/COLOR][COLOR=#00ffff]CarList[/COLOR][COLOR=#0000FF])
       [/COLOR][COLOR=#000000] objStreamReader.Close()[/COLOR][COLOR=#0000FF]
        Return [/COLOR][COLOR=#000000]CarList[/COLOR][COLOR=#0000FF]
    End Function

    Public Sub[/COLOR][COLOR=#000000] SaveCarList(Carlist[/COLOR][COLOR=#0000FF] As [/COLOR][COLOR=#00ffff]CarList[/COLOR][COLOR=#000000])[/COLOR][COLOR=#0000FF]
        Dim [/COLOR][COLOR=#000000]objStreamWriter[/COLOR][COLOR=#0000FF] As New [/COLOR][COLOR=#00ffff]StreamWriter[/COLOR][COLOR=#0000FF][/COLOR][COLOR=#000000]([/COLOR][COLOR=#00ffff]Application[/COLOR][COLOR=#000000].StartupPath &[/COLOR][COLOR=#0000FF] "\Resources\CarList.xml"[/COLOR][COLOR=#000000])[/COLOR][COLOR=#0000FF]
        Dim[/COLOR][COLOR=#000000] x[/COLOR][COLOR=#0000FF] As New [/COLOR][COLOR=#00ffff]XmlSerializer[/COLOR][COLOR=#000000](Carlist.GetType)[/COLOR][COLOR=#0000FF]
       [/COLOR][COLOR=#000000] x.Serialize(objStreamWriter, [/COLOR][COLOR=#00ffff]Carlist[/COLOR][COLOR=#000000])
        objStreamWriter.Close()[/COLOR][COLOR=#0000FF]
    End Sub

    Public Class [/COLOR][COLOR=#00ffff]CarList[/COLOR][COLOR=#0000FF]
        Private [/COLOR][COLOR=#000000]_Car_Make[/COLOR][COLOR=#0000FF] As New List(Of [/COLOR][COLOR=#00ffff]CarMake[/COLOR][COLOR=#0000FF])
        Public ReadOnly Property [/COLOR][COLOR=#000000]CarMake [/COLOR][COLOR=#0000FF]As List(Of [/COLOR][COLOR=#00ffff]CarMake[/COLOR][COLOR=#0000FF])
            Get
                Return [/COLOR][COLOR=#000000]_Car_Make[/COLOR][COLOR=#0000FF]
            End Get
        End Property
    End Class

    Public Class CarMake
        Public Property [/COLOR][COLOR=#000000]Name[/COLOR][COLOR=#0000FF] As String
        Private [/COLOR][COLOR=#000000]_Model[/COLOR] [COLOR=#0000FF]As New List(Of String)
        Private [/COLOR][COLOR=#000000]_Colour[/COLOR][COLOR=#0000FF] As New List(Of String)

        Public ReadOnly Property [/COLOR][COLOR=#000000]Model[/COLOR][COLOR=#0000FF] As List(Of String)
            Get
                Return[/COLOR][COLOR=#000000] _Model[/COLOR][COLOR=#0000FF]
            End Get
        End Property

        Public ReadOnly Property [/COLOR][COLOR=#000000]Colour[/COLOR][COLOR=#0000FF] As List(Of String)
            Get
                Return _Colour
            End Get
        End Property
    End Class
End Module[/COLOR]

VB.NET:
Dim carlist As New CarList
Dim TEMPcarmake As New CarMake


        carlist = GetCarList()[COLOR=#00ff00] 'This is a funtion that returns the hard copy of the list.[/COLOR]
        [COLOR=#00ff00]'so as far as i know, this variable should become a copy of the original list[/COLOR]

        With CB_Manufacture [COLOR=#00ff00]'should make the combobox.SelectItem be an item[/COLOR] [COLOR=#00ff00]of the class 'CarMake'[/COLOR]
             .DataSource = carlist.CarMake[COLOR=#00ff00] [/COLOR]
            .DisplayMember = "Name"
        End With
        
        carlist.CarMake.Remove(carlist.CarMake.Equals(TEMPcarmake.Name)) 'doesn't work
The problem i am having is here,
Tempcarmake has a Make property which holds the car make eg Honda, Ford, VW
i want to find the item in the that has the same Make as the TEMPcarmake that the user has been using
 
Back
Top