CorString: IsNullOrWhiteSpace

IsNullOrWhiteSpace

Returns if the string is null, empty or contains only white-space characters.



 Public Function IsNullOrWhiteSpace(
	  ByRef s As String ) As Boolean

Parameters

s
[ByRef] String. The string to be tested for white-space.

Return Values

Boolean -  True if the string has a length of zero or contains only white-space, False otherwise.

Remarks

IsNullOrWhiteSpace is a convenience method that is similar to the following code, except that it offers better performance:

Len(CorString.Trim(s)) = 0

White-space characters are defined by the Unicode standard. The IsNullOrWhiteSpace method interprets any character that returns a value of true when it is passed to the Char.IsWhiteSpace method as a white-space character.

Examples

The following example creates a string array, and then passes each element of the array to the IsNullOrWhiteSpace method.

Public Sub Main()
    Dim Values() As String
    Dim Value As Variant
    
    Values = NewStrings(vbNullString, "", "ABCDE", Space$(20), t("  \t  "), String$(&H2000, 10))
    
    For Each Value In Values
        Debug.Print CorString.IsNullOrWhiteSpace(CStr(Value))
    Next
End Sub

' The code produces the following output.
'
'    True
'    True
'    False
'    True
'    True
'    True

See Also

Project CorLib Overview

Class CorString Overview