Alan McGowan
Senior Member
- Outlook version
- Outlook 2013 64 bit
- Email Account
- Exchange Server
I have a text file that is in the following format (8 values per line)
txt1,txt2,txt3 etc
txt4,txt5,txt6 etc
txt7,txt8,txt9 etc
I am trying to populate a listbox with this information but I'm having no success. I was trying to use code similar to the following but keep getting a runtime error. I changed the column count to 8 and expanded the code under the .Additem
Any thoughts?
txt1,txt2,txt3 etc
txt4,txt5,txt6 etc
txt7,txt8,txt9 etc
I am trying to populate a listbox with this information but I'm having no success. I was trying to use code similar to the following but keep getting a runtime error. I changed the column count to 8 and expanded the code under the .Additem
Code:
Dim fn As String, ff As Integer, txt As String
fn = "d:\filemail\folders.txt" '< --- .txt file path
txt = Space(FileLen(fn))
ff = FreeFile
Open fn For Binary As #ff
Get #ff, , txt
Close #ff
Dim myArray() As String
Dim j As Integer
myArray = Split(txt, vbCrLf)
'Use .List method to populate listbox.
With ListBox1
.ColumnCount = 2
For j = 0 To UBound(myArray)
.AddItem
.List(j, 0) = Split(myArray(j), ",")(0)
.List(j, 1) = Split(myArray(j), ",")(1)
Next j
End With
Any thoughts?