Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 970
  • Last Modified:

vb6 - load file into listview without split

hello there,
I have this code that will load a text file into a listview but if the text file has name1:lastname1 it will split it!!
now I only have name name1 so I dont need the split..

this is the code I am using

Public Sub LoadFile(mPath As String, LVW As ListView)
    LVW.ListItems.Clear
    Set fso = New FileSystemObject
    Set TS = fso.OpenTextFile(mPath, ForReading, False)
    While Not TS.AtEndOfStream
      tabLine = Split(TS.ReadLine, ":")
          Set lItem = LVW.ListItems.Add(, , tabLine(0))
          lItem.ListSubItems.Add , , tabLine(1)
    Wend
    TS.Close
    Set TS = Nothing
    Set fso = Nothing
End Sub
0
Sabrin
Asked:
Sabrin
1 Solution
 
jpaulinoCommented:
Change it to this:

Public Sub LoadFile(mPath As String, LVW As ListView)
    LVW.ListItems.Clear
    Set fso = New FileSystemObject
    Set TS = fso.OpenTextFile(mPath, ForReading, False)
    While Not TS.AtEndOfStream
          Set lItem = LVW.ListItems.Add(, , TS.ReadLine)
    Wend
    TS.Close
    Set TS = Nothing
    Set fso = Nothing
End Sub

You also need to delete the second column of the listview
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now