Parsing a Text Variable

Posted on 2008-11-11
Last Modified: 2012-05-05

I am extracting and unencypting a small text file (sFilePath) that contains multiple lines to a variable (sFileChunk).  Once I have the variable how can I loop through each "line" as I would using the FileSystemObject f.ReadLine method?

I cannot use the ReadLine method as the usable contents are in variable.  I do not want to write it out to a temp file to do this for security reasons.

What can you recommend?


'Get File Contents

dim fso,f, sFileChunk

set fso = Server.CreateObject("Scripting.FileSystemObject")

set f = fso.OpenTextFile(sFilePath, 1)

sFileChunk = decrypt(f.ReadAll)


Open in new window

Question by:michael4606
    LVL 8

    Accepted Solution

    You should be able to split the file into an array using the newline character as a delimiter:
    arrLines = Split(sFileChunk, vbCrLf)
    '     Now cycle through the array to operate on each line
    For i = 0 to uBound(arrLines)
         Response.Write(arrLines(i) & "<br>")

    Author Closing Comment


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Free Trending Threat Insights Every Day

    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.

    Suggested Solutions

    I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
    I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    737 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

    16 Experts available now in Live!

    Get 1:1 Help Now