Hello all,
I am trying to load data of text file (which is comma delimited and is in the same application folder), into a listview control.The data is coming in list view but in the first column in list view there is a problem.Can somebody help me to solve this problem.:If desired I can provide sample provide on this.
Here is the vb6 code:
Option Explicit
Private Sub cmdGo_Click()
Dim file_name As String
Dim fnum As Integer
Dim whole_file As String
Dim lines As Variant
Dim num_rows As Long
Dim the_array() As Variant
Dim R As Long
Dim C As Long
Dim litem As ListItem
file_name = App.Path
If Right$(file_name, 1) <> "\" Then file_name = file_name & "\"
file_name = file_name & "test.txt"
' Loading file.
fnum = FreeFile
Open file_name For Input As fnum
whole_file = Input$(LOF(fnum), #fnum)
Close fnum
lines = Replace(whole_file, Chr$(10), vbCrLf)
' Break the file into lines.
lines = Split(whole_file, vbCrLf)
' Dimension the array.
num_rows = UBound(lines)
ReDim the_array(num_rows)
' Copy the data into the array.
For R = 0 To num_rows
the_array(R) = Split(lines(R), ",")
Next R
' confirm that we have the data loaded.
For R = 0 To UBound(the_array)
Set litem = LVW.ListItems.Add(, , lines(0))
For C = 1 To UBound(the_array(R))
Debug.Print the_array(R)(C) & ",";
litem.ListSubItems.Add , , the_array(R)(C)
Next C
Next R
End Sub
Thanks to all members