Re: How to Read From a Carriage Return File.
From: Mythran (kip_potter_at_hotmail.com)
Date: 09/15/04
- Next message: Chris Lane: "How many bits is this script?"
- Previous message: Anthony: "Message to Users"
- In reply to: Mythran: "Re: How to Read From a Carriage Return File."
- Next in thread: Jamie Baker: "Re: How to Read From a Carriage Return File."
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 15 Sep 2004 08:48:21 -0700
Hope this helps some more :)
Option Explicit
DisplayFile "C:\readme.txt"
Sub DisplayFile(ByVal Path)
Dim fso
Dim stream
Dim ch
Dim line
Dim text
Set fso = CreateObject("Scripting.FileSystemObject")
Set stream = fso.OpenTextFile(Path, 1, False)
Do Until stream.AtEndOfStream
ch = stream.Read(1)
If ch = vbCr Then
MsgBox "Current Line: " & line
' Do something with the line.
text = text & line & vbCrLf ' Append line and carriage-return and
line-feed.
line = ""
ElseIf ch = vbLf Then
MsgBox "Line Feed Found, ignoring."
Else
line = line & ch
End If
Loop
If line <> "" Then
text = text & line
End If
MsgBox "File Text: " & vbCrLf & text
stream.Close
Set stream = Nothing
Set fso = Nothing
End Sub
"Mythran" <kip_potter@hotmail.com> wrote in message
news:Ok6$rgamEHA.3900@TK2MSFTNGP10.phx.gbl...
> Option Explicit
>
> MsgBox(ReadFile("C:\readme.txt"))
>
> Function ReadFile(ByVal Path)
> Dim fso
> Dim stream
>
> Set fso = CreateObject("Scripting.FileSystemObject")
> Set stream = fso.OpenTextFile(Path, 1, False)
>
> ReadFile = stream.ReadAll()
>
> stream.Close
>
> Set stream = Nothing
> Set fso = Nothing
> End Function
>
> OR...
>
> Option Explicit
>
> DisplayFile "C:\readme.txt"
>
> Sub DisplayFile(ByVal Path)
> Dim fso
> Dim stream
>
> Set fso = CreateObject("Scripting.FileSystemObject")
> Set stream = fso.OpenTextFile(Path, 1, False)
>
> Do Until stream.AtEndOfStream
> MsgBox(stream.ReadLine())
> Loop
>
> stream.Close
> Set stream = Nothing
> Set fso = Nothing
> End Sub
>
> Hope this helps :)
>
> Mythran
>
- Next message: Chris Lane: "How many bits is this script?"
- Previous message: Anthony: "Message to Users"
- In reply to: Mythran: "Re: How to Read From a Carriage Return File."
- Next in thread: Jamie Baker: "Re: How to Read From a Carriage Return File."
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|