Solved

Problem Ectracting Text From Inet to List

Posted on 2004-09-16
7
170 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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

706 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

11 Experts available now in Live!

Get 1:1 Help Now