Solved

Ending ReadLine at EOF

Posted on 2002-05-15
3
1,645 Views
Last Modified: 2012-08-14
Using the Object FSO I want to read each line to a variable. Some sample for clarity:

Set objTextStream = objFSO.OpenTextFile(FileToOpen, 1)
'Want to have line below read until EOF
txtMsg = objTextStream.ReadLine

What is the syntax for EOF so it does not error out?
0
Comment
Question by:dmoring
  • 2
3 Comments
 
LVL 3

Expert Comment

by:tejaspurani
ID: 7011390
objTextStream.AtendOfStream  


T.P.
0
 
LVL 3

Accepted Solution

by:
tejaspurani earned 50 total points
ID: 7011394

<%
Option Explicit
' Set up constants
Const ForReading = 1
Const Create = False

' Declare local variables
Dim objFSO         ' FileSystemObject
Dim objTextStream  ' TextStreamObject
Dim strLine        ' local variable to store Line
Dim strFileName    ' local variable to store fileName

strFileName = Server.MapPath("textfile.txt")

' Instantiate the FileSystemObject
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")

' use Opentextfile Method to Open the text File
Set objTextStream = objFSO.OpenTextFile(strFileName, ForReading, Create)

If Not objTextStream.AtEndOfStream  Then  

Do While Not objTextStream.AtendOfStream  

strLine = objTextStream.ReadLine ' Read one line at a time
Response.Write strLine ' Display that line
Response.Write "<br>"  
 
Loop

End If

' close TextStreamObject
' and destroy local variables to relase memory
objTextStream.Close
Set objTextStream = Nothing
Set objFSO = Nothing
%>
0
 

Author Comment

by:dmoring
ID: 7059009
Worked great!!! Thank you!
0

Featured Post

Independent Software Vendors: 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

Suggested Solutions

Title # Comments Views Activity
RegEx Help - open to other simple suggestions 8 63
age from date of birth 4 57
2012 SQL to JSON Select 5 29
VB script help 23 30
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

740 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