vbMarkO Posted July 21, 2006 Posted July 21, 2006 My code will add all the last names to a combobox but how can I change this so it will add to an array? 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 Quote Visual Basic 2008 Express Edition!
Cags Posted July 21, 2006 Posted July 21, 2006 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. Quote Anybody looking for a graduate programmer (Midlands, England)?
vbMarkO Posted July 21, 2006 Author Posted July 21, 2006 Thank you this worked great!!! RESOLVED vbMarkO Quote Visual Basic 2008 Express Edition!
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.