Click here to Skip to main content
15,886,919 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi friends,

i'm new in vb6,now i need to display the textfile to listview format.

i have the textfile name is post.txt ,now i want to display those text file details to listview format in vb6,these listview have a four columns with length like postalcode(6),addresstype(1),buildingnumber(7),streetkey(7),buildingkey(6).

my textfile is:

/here 019191 - postalcode,K-addresstype,31-buildingnumber,MAR0043-streetkey,MAR036-building key

019191K31 MAR0043MAR036
019392K20 MAR0042
019393K26 MAR0042GAR006
019394K28 MAR0042GAR006
019395K30 MAR0042GAR006
019596K5 MAR0041
118484K PAS0007PAS039
038983K3 TEM0002SUN048
048425U21 TEL0003
048426U23 TEL0003
048427U25 TEL0003
048428U27 TEL0003
908005P ROB004
908006P ROB004
908007W ROB004
908005P ROB004



i serach alredy many sites but not helpful,i hope i find the solution for this problem via codeproject.

if anybody know the solution for this please share and advise me.

thanks,
renga
Posted
Comments
Richard MacCutchan 27-May-13 4:06am    
Read the file one line at a time, split the line into its component parts and add each field to the relevant column of the ListView. Which part of this are you not able to figure out?
Renga.g 27-May-13 5:36am    
i'm totally blank,i don't know how to use fully,can you show me some sample code's for my reference.

thanks
Richard MacCutchan 27-May-13 7:36am    
Try reading the this, and this, it's amazing what you can learn.
Renga.g 27-May-13 22:34pm    
kindly please can you give me the sample reference code?
Renga.g 3-Jun-13 2:34am    
hi i solve this problem,thanks.

1 solution

this code is for vb.net bt not much diffrence for vb6 you can change it..
VB
Dim sr As StreamReader = New StreamReader("Your File Path")
 Dim Arr() As String
 Dim line As String
 While sr.Read
     If sr.EndOfStream Then
         Exit While
     End If
     line = sr.ReadLine
     Arr = line.Split(",")
     ListView1.Items(0).Text = Arr(0) 'Assign your listview acc to your need
     ListView1.Items(1).Text = Arr(1)
     ListView1.Items(2).Text = Arr(2)
     ListView1.Items(3).Text = Arr(3)
 End While
 
Share this answer
 
Comments
Renga.g 27-May-13 5:33am    
i use this process already but i have the error of streamreader,and also i'm blank how to get the streamreader in vb6.
Basmeh Awad 27-May-13 5:37am    
what is the error you are getting???streamreader is same like this in vb6...
your problem solved or not???
Renga.g 27-May-13 22:34pm    
sorry, i'm new in vb6,if i use this function in vb6 don't have the StreamReader (build in function),
then how i use this,is have any other way to use StreamReader?
Basmeh Awad 28-May-13 2:42am    
try this...
Dim fileReader As System.IO.StreamReader
fileReader = _
My.Computer.FileSystem.OpenTextFileReader("C:\\testfile.txt")
Dim stringReader As String
stringReader = fileReader.ReadLine()
MsgBox("The first line of the file is " & stringReader)
Renga.g 3-Jun-13 2:34am    
Hi sorry, for the delay replay, Thank you very much for your help.
Finally i solved this problem,by use TEXTSTREAM and FSO.

Once again thanks for your time and consideration.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900