Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old August 21st, 2005, 06:53 AM
pgolovko pgolovko is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Aug 2005
Posts: 2 pgolovko User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 49 m 32 sec
Reputation Power: 0
Question fetch text file from the web into ListView control?

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.

Reply With Quote
  #2  
Old August 21st, 2005, 04:05 PM
Doug G Doug G is offline
Grumpier Old Moderator
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Sep 2003
Posts: 10,143 Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 23 h 29 m 58 sec
Reputation Power: 181
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

Reply With Quote
  #3  
Old August 21st, 2005, 09:15 PM
pgolovko pgolovko is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Aug 2005
Posts: 2 pgolovko User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 49 m 32 sec
Reputation Power: 0
Thank you for reply Doug. Could you please show me how to do this in code? I'm really new to Visual Basic.

Reply With Quote
  #4  
Old September 5th, 2005, 04:32 PM
Alias-Zero Alias-Zero is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Sep 2005
Location: localhost
Posts: 40 Alias-Zero User rank is Lance Corporal (50 - 100 Reputation Level)Alias-Zero User rank is Lance Corporal (50 - 100 Reputation Level)Alias-Zero User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 14 h 44 m 12 sec
Reputation Power: 4
Send a message via ICQ to Alias-Zero Send a message via AIM to Alias-Zero Send a message via MSN to Alias-Zero Send a message via Yahoo to Alias-Zero
Quote:
Originally Posted by pgolovko
Thank you for reply Doug. Could you please show me how to do this in code? I'm really new to Visual Basic.


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

Reply With Quote
  #5  
Old September 5th, 2005, 10:28 PM
Doug G Doug G is offline
Grumpier Old Moderator
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Sep 2003
Posts: 10,143 Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 23 h 29 m 58 sec
Reputation Power: 181
Quote:
I'm not Doug, but this should work.
You are SO lucky!!!

Thanks for helping out!.

Reply With Quote
  #6  
Old September 6th, 2005, 06:07 PM
Alias-Zero Alias-Zero is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Sep 2005
Location: localhost
Posts: 40 Alias-Zero User rank is Lance Corporal (50 - 100 Reputation Level)Alias-Zero User rank is Lance Corporal (50 - 100 Reputation Level)Alias-Zero User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 14 h 44 m 12 sec
Reputation Power: 4
Send a message via ICQ to Alias-Zero Send a message via AIM to Alias-Zero Send a message via MSN to Alias-Zero Send a message via Yahoo to Alias-Zero
Quote:
Originally Posted by Doug G
You are SO lucky!!!

Thanks for helping out!.


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.

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > fetch text file from the web into ListView control?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT