Since function isNonEmptyString
uses some non-built VBA functions, they also must be included in your code for the function to work properly.
Otherwise the following error will occur: Compile error: Sub or Function not defined.
Required functions are listed below. You can get to each function's source code by clicking its name:
When adding the functions above to your VBA project, make sure you haven't done it before. If there are two different public functions with the same name in a single VBA project, the following compilation error is thrown: Compile error: Ambiguous name detected: function_name.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
'**********************************************************************************************************
' Name: isNonEmptyString
' Author: mielk | 2014-09-20
'
' Description: Function to check if the given value is a non-empty string.
' Note that strings consisting only of blank characters (i.e. spaces) are also
' considered to be an empty string.
'
' Parameters:
' value Value to be checked.
'
'
' Returns:
' Boolean True is returned only if the given value or its text representation is a non-empty
' string.
' False value is returned in a few cases:
' * the source parameter [value] is an empty string,
' * the source parameter [value] is a string consisting only of blank characters,
' * the source parameter [value] is not a string and cannot be converted into
' string (i.e it is object or array).
'
'
'
' --- Changes log -----------------------------------------------------------------------------------------
' 2014-09-20 mielk Function created.
'**********************************************************************************************************
Public Function isNonEmptyString(ByVal value As Variant) As Boolean
Const METHOD_NAME As String = "isNonEmptyString"
'------------------------------------------------------------------------------------------------------
If Not VBA.IsObject(value) Then
isNonEmptyString = VBA.Len(removeSpaces(stringify(value))) > 0
End If
End Function