How to Parse a comma delimited txt file?

Posted on 2004-11-22
Last Modified: 2010-04-24
I'm a noob so I'm not sure how to put this exactly.
I'd like to parse a comma delimited text file into an (array?) and use the contents of the array to fill in a webform.

Ralph,Malph,123 st, etc....

I've already got the webform portion handled but I've been getting my data from labels I have on my form ie:

Dim FirstName As String
FirstName = lblFirstName.Text
.Document.Frames("Main").document.Forms(0)("app_first_name").Value = FirstName

But thats kinda cheating, I'd like to do it without using labels, just pull the data from memory.

How would I go about doing that?
Question by:Matrix1000
    LVL 85

    Accepted Solution

    Something like this?...

            Dim fileName As String = "C:\someFile.txt"
            If Not File.Exists(fileName) Then
                MsgBox(fileName, MsgBoxStyle.Critical, "File Not Found")
                Exit Sub
            End If

            Dim sr As StreamReader = New StreamReader(fileName)
            Dim inputLine As String = sr.ReadLine
            If Not (inputLine Is Nothing) Then
                Dim values() As String = Split(inputLine, ",")
                .Document.Frames("Main").document.Forms(0)("app_first_name").Value = values(0)
                .Document.Frames("Main").document.Forms(0)("app_last_name").Value = values(1)
                ' etc...
            End If
    LVL 1

    Author Comment

    THANKS!  but I get an error underlining "File"  in  "If Not File.Exists(fileName) Then"

    Says its not declared.
    What do I need do do to make it work?
    LVL 14

    Assisted Solution

    Add the following to your file OUTSIDE the class declaration:

    Imports System.IO

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
    Introduction When many people think of the WebBrowser ( control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    758 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