Advertisement
C_Volume2 Files/ File Controls/ Input/ Output #67696

Read Write

read a text file and convert it into an array

AI

Riepilogo AI: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Codice sorgente
original-source
'Purpose:This class is used to read and create files text files
'Dependancies:must add Reference Microsoft Scripting Runtime
'Creation Date: ?
'Author: Brent Luyet
'Revision  Date  Revision By
'1.02    3/30/03 BJL
Public Function read(InFile As String, outArray() As String)
'Purpose:This function receives a filename and returns values in an array
'Creation Date:?
'Author: Brent Luyet
'Revision  Date  Revision By
'1.01    1/30/03 mst
Dim fso As New FileSystemObject   'must add Reference Microsoft Scripting Runtime
Dim fts As TextStream
Dim inString As String       'temp value to hold string read from file
Set fts = fso.OpenTextFile(InFile, ForReading, False) 'open infile for read only
inString = fts.ReadAll       'read entire file into inString
outArray = Split(inString, vbCrLf) 'split inString into outArray
'Clean up
fts.Close
Set fts = Nothing
Set fso = Nothing
End Function
Public Function WriteFile(ByVal OutFile As String, ByRef outArray() As String)
'Purpose:This function will create a file using the values passed in the value out array
'Creation Date: Date Class was created
'Author: Brent Lyute
'Revision  Date  Revision By
'1.01    1/30/03 mst
Dim fso As New FileSystemObject 'must add Reference Microsoft Scripting Runtime
Dim fts As TextStream
Dim OutString As String     'temp val for holding array before writing to file
OutString = Join(WriteOut, vbCrLf) 'join array to temp string outString
Set fts = fso.OpenTextFile(OutFile, ForWriting, True) 'Open OutFile for write, overwrite
fts.Write OutString ' Write temp string outString to OutFile
'Clean UP
fts.Close
Set fts = Nothing
Set fso = Nothing
End Function
Commenti originali (3)
Recuperato da Wayback Machine