|
|
CODE ' Code courtesy of UtterAccess Wiki
' http://www.utteraccess.com/wiki/index.php/Category:FunctionLibrary ' Original submission by Walter Niesz ' June 8, 2011 ' ' DESCRIPTION ' When dealing with unicode files, you cannot easily use the standard LINE INPUT method of the OPEN statement. ' This is particularly so when the End-Of-Line characters are not the standard CarriageReturn/LineFeed combinations. ' This routine will read in a unicode file and parse the lines of data into an array so that they can be easily manipulated. Public Function GetUnicodeFileIntoArray(Filename As String, EndOfLineCharacters As String) ' returns a string array containing each row of data contained in the file ' example usage: ' MyArray = GetUnicodeFileIntoArray("C:\MyFile.txt", vbLf) ' this would indicate that LineFeed characters were used as End-Of-Line markers Dim Buffer As String Buffer = Space(FileLen(Filename)) Open Filename For Binary Access Read As #1 Get #1, , Buffer 'Place entire contents of file in Buffer Close #1 Buffer = StrConv(Buffer, vbFromUnicode) 'convert unicode text over to standard strings GetUnicodeFileIntoArray = Split(Buffer, EndOfLineCharacters) 'break apart the lines of data and insert them into an array End Function
|
| This page was last modified 14:15, 8 June 2011. This page has been accessed 274 times. Disclaimers |