This adds to a combo but how can it add to an array

vbMarkO

Well-known member
Joined
Aug 19, 2005
Messages
157
My code will add all the last names to a combobox but how can I change this so it will add to an array?


Code:
Sub DisplayRecords()
        Dim xmlTr As New XmlTextReader(xmlFile)
       
        While xmlTr.Read
            If xmlTr.Name = "Last_Name" AndAlso xmlTr.NodeType = XmlNodeType.Element Then
                cboMembers.Items.Add(xmlTr.ReadString)  Adds to combobox but need it in an array


            End If
        End While
        xmlTr.Close()
        


        xmlDoc = New XmlDocument
        xmlDoc.Load(xmlFile)

        If File.Exists(xmlFile) Then
            dsChurchMem.ReadXml(xmlFile)
        End If
    End Sub

Any ideas, I know this shouldnt be hard but for the life of me, I cant remember.... I went blank... I have a few tries but I am missing something so I am in hopes you all will point the way

vbMarkO
 
Code:
Sub DisplayRecords()
        Dim xmlTr As New XmlTextReader(xmlFile)
        Dim myArrayList as New ArrayList()
        While xmlTr.Read
            If xmlTr.Name = "Last_Name" AndAlso xmlTr.NodeType = XmlNodeType.Element Then
                myArrayList.Add(xmlTr.ReadString) 


            End If
        End While
        xmlTr.Close()
You can add to an arraylist as follows, if you required a typed array you could create it afterwards (when you know how many elements their are) and copy the items over from the arraylist.
 
Back
Top