|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
The "file.txt" is a plain ASCII line-delimited database:
Code:
first line here second line here another line here few more lines here some more and here too and more here and so on So far I got this: Code:
Private Sub Command1_Click() On Error Resume Next ListView1.ListItems.Add = Inet1.OpenURL End Sub Private Sub Form_Load() Inet1.URL = "http://www.server.com/file.txt" End Sub The above adds the whole file to the first line of ListView. Is there a way to fill ListView with "file.txt" line by line? I guess there should be a FOREACH statement somewhere to go over the database line by line adding each line to the ListView control. Thank you in advance. |
|
#2
|
|||
|
|||
|
You could read the file.txt into a local variable. Then split the local variable on line breaks and add to the listview line by line.
__________________
====== Doug G ====== I didn't attend the funeral, but I sent a nice letter saying I approved of it. --Mark Twain |
|
#3
|
|||
|
|||
|
Thank you for reply Doug. Could you please show me how to do this in code? I'm really new to Visual Basic.
|
|
#4
|
|||
|
|||
|
Quote:
Code:
Private Sub Command1_Click() On Error Resume Next ListView1.ListItems.Add = Inet1.OpenURL End Sub Private Sub Form_Load() Inet1.URL = "http://www.server.com/file.txt" End Sub I'm not Doug, but this should work. Code:
Private Sub Command1_Click() On Error Resume Next dim blah as string blah = Inet1.OpenURL AddToList = Split(blah, vbcrlf) With ListView1 .listitems.add = AddToList(0) .listitems.add = AddToList(1) .listitems.add = AddToList(2) .listitems.add = AddToList(3) .listitems.add = AddToList(4) .listitems.add = AddToList(5) .listitems.add = AddToList(6) .listitems.add = AddToList(7) End With End Sub Private Sub Form_Load() Inet1.URL = "http://www.server.com/file.txt" End Sub |
|
#5
|
|||
|
|||
|
Quote:
![]() Thanks for helping out!. |
|
#6
|
|||
|
|||
|
Quote:
No problem ;-P Forgot to mention, if the array is not the same everytime and the ubound changes you can use this instead to add all of the array to the listview Code:
Dim Blah As String
Blah = Inet1.OpenURL
Blah2 = split(Blah, vbCrLf)
For i = 0 To UBound(Blah2)
ListView1.ListItems.Add = Blah2(i)
Next
Or you can use that anyways, its probably a lot cleaner. |
![]() |
| Viewing: ASP Free Forums > Programming > Visual Basic Programming > fetch text file from the web into ListView control? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|