Solved

Problem Ectracting Text From Inet to List

Posted on 2004-09-16
7
177 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 86

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 86

Expert Comment

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

Idle_Mind
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

726 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