B4J Code Snippet IsEmptyString() function

My first tip for B4J.

IsEmptyString(); Returns True if x parameter is empty string or null

B4X:
Public Sub IsEmptyString(x As String) As Boolean
      
  
    Dim bEmpty As Boolean
  

    bEmpty = x = Null      ' Because pure Null
  
 
    If Not( bEmpty ) Then
      
        bEmpty = x.CompareTo(Null) = 0   ' Because origin is field of table bbdd
       
        If Not( bEmpty ) Then         

            Dim cTrim As String = x.Trim
           
            bEmpty = cTrim.Length < 1

        End If

    End If  

    Return bEmpty

End Sub
 

amminf

Active Member
Licensed User
Longtime User
I think that not so.

From data field is value null (without quotation marks, it is not a string), but is a special null, different to b4j null constant

From Phill Griffiths sample: "My database table contains an integer field which has a value of null"
 
Top