Function String Searches Class

CountLines

Count the number of lines within a string. Works for Windows, DOS, and UNIX strings since it considers the line feed character to be the line terminator.

Signature (Visual Basic / VBA)

Public Function CountLines( _
    ByVal vValue As Variant _
    ) As Variant

Code Example

    CountLines("One." + vbCrLf + "Two") = 2
    CountLines("One." + vbCrLf + "Two" + vbCrLf) = 2

Parameters

Parameter Description
vValue The string containing the lines of text to be counted. Function returns Null if vLine is Null or cannot be fixed up to a String. Uses the CountStrings function to determine the number of line terminators within the string.