Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Problem Ectracting Text From Inet to List

Posted on 2004-09-16
7
Medium Priority
?
184 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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 2000 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

Industry Leaders: 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!

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…
Suggested Courses

609 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