dimanche 10 mai 2015

join arrays and find matches

So i'm working on a project and i've hit a bit of a roadblock. i'm trying to compare two arrays that've been populated with read-in and split text files, find the matches of individual elements (names), then populate a listbox with the resulting matches. here's the code i have so far:

Dim sr As IO.StreamReader
Dim sw As IO.StreamWriter
Dim guest As String()
Dim gift As String()

Private Sub frmTYC_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    Dim strFile1 As String
    Dim strFile2 As String
    Dim intCount As Integer

    strFile1 = "Guests.txt"
    strFile2 = "Gifts.txt"

    intCount = 0
    sr = IO.File.OpenText(strFile1)
    Do While sr.Peek <> -1
        guest = sr.ReadLine.Split(",")
        lstGuests.Items.Add(guest(0))
        intCount += 1
    Loop
    sr.Close()

    intCount = 0
    sr = IO.File.OpenText(strFile2)
    Do While sr.Peek <> -1
        gift = sr.ReadLine.Split(",")
        lstGifts.Items.Add(gift(1) & " " & "gifted" & " " & gift(0))
        intCount += 1
    Loop
    sr.Close()
End Sub

Private Sub btnList_Click(sender As Object, e As EventArgs) Handles btnList.Click

End Sub

i'm trying to compare guest(0) and gift(1) as those are the names, with guest having all the names and gift having all the names of the people in guest who gave a gift. i need the listbox to be populated on the list button click

Aucun commentaire:

Enregistrer un commentaire