ReadTextFile

Reads a text file from disk and returns the text as an array of strings. ANSI, UTF-8 and Unicode encoded text files are supported.

Syntax

Rhino.ReadTextFile (strFileName [, blnIgnoreEmptyRows [, blnTrimSpaces]])

Parameters

strFileName

Required.  String.  The name of an existing text file to read.  

blnIgnoreEmptyRows

Optional.  Boolean.  If omitted or False (Default), then if an empty line is encountered in the text file, an empty element (vbEmpty) will be added to the string array. If True, then empty line will be skipped.

blnTrimSpaces

Optional.  Boolean.  If omitted or False (Default), then leading and trailing spaces, for each line of text that is read, will not be trimmed.  If True, then leading and trailing spaces will be trimmed.

Returns

Array

An array of strings, if successful.

Null

On error.

Example

Dim strFile, arrText, i

strFile = Rhino.OpenFileName("Open", "Text Files (*.txt)|*.txt||")

If Not IsNull(strFile) Then

  arrText = Rhino.ReadTextFile(strFile)

  If IsArray(arrText) Then

    For i = 0 To UBound(arrText)

      Call Rhino.Print(arrText(i))

    Next

  End If

End If

Also See

ReadDelimitedFile