Solved

Problem Ectracting Text From Inet to List

Posted on 2004-09-16
7
172 Views
Last Modified: 2010-05-02
I'm trying to list a items in a textfile into a listbox, it does add the item to the box but its adding it all into one line. ive tried splitting it with vbnewline but it dosnt seem to fix the problem, it loads Squares to replace the new line. how can i fix this
0
Comment
Question by:andyakira
7 Comments
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 12080387
Option Explicit

Private Sub Command1_Click()
    populateListBox "c:\someFile.txt"
End Sub

Private Sub populateListBox(ByVal fileName As String)
    If Dir(fileName) <> "" Then
        Dim ff As Integer
        Dim inputLine As String
       
        List1.Clear
        ff = FreeFile
        Open fileName For Input As #ff
        While Not EOF(ff)
            Line Input #ff, inputLine
            List1.AddItem inputLine
        Wend
        Close #ff
        MsgBox "Import Complete", vbInformation, "File Import"
    Else
        MsgBox "File not found: " & fileName, vbCritical, "File Import"
    End If
End Sub
0
 

Author Comment

by:andyakira
ID: 12080408
I mean listing a text file from a url to a list box
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 12080430
Can you show me how you are downloading the text file right now?

Idle_Mind
0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
LVL 19

Expert Comment

by:RanjeetRain
ID: 12080437
THere are two parts of your problem (I have had a bit of difficulty understanding you too).

One is that it comes in one line and the second is it adds squares. You will be glad to know that both problems can be fixed simultaneously.

If you are trying to read the content of a listbox and dump it INTO a text file, the code would be like:

handle = Freefile()
dim filename for output as handle
For i = 0 to list1.count
    Print #handle, list1.list(i)
Next
close #handle


0
 

Author Comment

by:andyakira
ID: 12080669
   Dim MyLines As Variant
    Dim i As Long
    MyLines = Split(Inet1.OpenURL("http://www.ietf.org/rfc/rfc2616.txt"), vbNewLine)
    For i = LBound(MyLines) To UBound(MyLines)
   List1.AddItem MyLines(i)
   Next i
0
 

Author Comment

by:andyakira
ID: 12080676
that is what i'm using. it adds it all into one line ;{
0
 
LVL 5

Accepted Solution

by:
KarcOrigin earned 500 total points
ID: 12080707
Try this:

Dim MyLines() As String
    Dim i As Long
    MyLines = Split(Inet1.OpenURL("http://www.ietf.org/rfc/rfc2616.txt"), Chr(10))
    For i = LBound(MyLines) To UBound(MyLines)
     List1.AddItem MyLines(i)
    Next i
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

816 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now