Hi all i am using the following code to load text to two listbox. However, i want to change it so it loads data into listview. Could any one show me how this can be done?
I tried to use:
but i got run time error 13 data mismatch !!
The data stored in text files are like this:
the power of love.mp3 c:\music\the power of love.mp3
the wall.mp3 c:\music\wind.mp3
......
I want song title and path be stored in seperate columns of listview.Hope you guys help me achive this task. Looking forward for reply.Thanks
I tried to use:
Code:
ListView1.ListItems.Add strBuffArr(0)
The data stored in text files are like this:
the power of love.mp3 c:\music\the power of love.mp3
the wall.mp3 c:\music\wind.mp3
......
I want song title and path be stored in seperate columns of listview.Hope you guys help me achive this task. Looking forward for reply.Thanks
Code:
Dim i As Long
Dim intLB As Long 'Is an index counter
Dim lngCtr As Long 'Represents the count of individual lines of data
Dim strOpenPathFile As String, strArr() As String, strBuffArr() As String
With CommonDialog1
.CancelError = True
On Error GoTo CommDiaCancelled
.Filter = "Text Files (*.txt)|*.txt|Word Doc (*.doc)|*.doc"
.ShowOpen
End With
strOpenPathFile = CommonDialog1.FileName
Open strOpenPathFile For Input As #1
strArr = Split(Input(LOF(1), 1), vbCrLf)
Close #1
'Clear all the ListBoxs
List1.Clear
List2.Clear
lngCtr = UBound(strArr)
For intLB = 0 To lngCtr
CommDiaCancelled:
If Err.Number = 32755 Then
MsgBox "Cancel selected !"
Exit Sub
End If
'Check for unwanted vbCrLf (which would yeild a "")
If Len(strArr(intLB)) <> 0 Then
'Split the Line of data
strBuffArr = Split(strArr(intLB), vbTab)
'Load the data into the ListBoxs
List1.AddItem strBuffArr(0)
List2.AddItem strBuffArr(1)
End If
Next