Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

Visual Basic 2008 Express Edition!
Posted

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.

Anybody looking for a graduate programmer (Midlands, England)?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...