Hello. I have this piece of code:
vb Code:
Public Sub LoadContact() With frmMain If IO.File.Exists(Application.StartupPath & "\Info\Contacts.vis") Then Dim sr As New IO.StreamReader(Application.StartupPath & "\Info\Contacts.vis") While (sr.EndOfStream <> True) Dim sLine As String = sr.ReadLine Dim sSI() As String = Split(sLine, "|") sTitle.Add(sSI(0)) sFullName.Add(sSI(1)) sPhone.Add(sSI(2)) sExt.Add(sSI(3)) sFax.Add(sSI(4)) sAddress1.Add(sSI(5)) sAddress2.Add(sSI(6)) sAddress3.Add(sSI(7)) sCity.Add(sSI(8)) sState.Add(sSI(9)) sZipCode.Add(sSI(10)) sEmail.Add(sSI(11)) ContactInfo.Add(sTitle(iCount).ToString & "|" & sFullName(iCount).ToString & "|" & _ sPhone(iCount).ToString & "|" & sExt(iCount).ToString & "|" & _ sFax(iCount).ToString & "|" & sAddress1(iCount).ToString & "|" & _ sAddress2(iCount).ToString & "|" & sAddress3(iCount).ToString & "|" & _ sCity(iCount).ToString & "|" & sState(iCount) & "|" & _ sZipCode(iCount).ToString & "|" & sEmail(iCount).ToString) .lstContacts.BeginUpdate() .lstContacts.Items.Clear() For i As Integer = 0 To UBound(ContactInfo.ToArray) .lstContacts.Items.Add(sFullName(i)) .lstvwContacts.Items.Add(sTitle(i)) Dim lstitm1, lstitm2, lstitm3 As New ListViewItem.ListViewSubItem lstitm1.Text = sFullName(i) lstitm2.Text = sAddress1(i) lstitm3.Text = sEmail(i) .lstvwContacts.Items(iCount).SubItems.AddRange(New ListViewItem.ListViewSubItem() {lstitm1, lstitm2, lstitm3}) Next .lstContacts.EndUpdate() iCount += 1 End While sr.Close() End If End With End Sub
So what it does, is it reads the contents of a text file and then loads all the info into a listarray, then I add those contents into a listview. Whats happening is:
say I have
123 123 123 123
1234 1234 1234 1234
in my Text File
When It loads to my ListView it does this
123 123 123 123
1234 1234 1234 1234
1234
It adds the Last Item Twice, but, only in the first column.
Whats my Issue and how can I fix this?




Reply With Quote