E Eduard Active Member Licensed User Longtime User Feb 5, 2013 #1 Code: Copy Dim x As String x = Null If x = Null Then Msgbox("x=null","") Else Msgbox("x<>null","") End If If x="" Then Msgbox("weird","") End If If x="null" Then Msgbox("o no!","") End If The expected behavior would be that x = null would evaluate to true since this is the way in B4A to check for null values. However. x = "null" evaluates to true! I believe this is a bug.
Code: Copy Dim x As String x = Null If x = Null Then Msgbox("x=null","") Else Msgbox("x<>null","") End If If x="" Then Msgbox("weird","") End If If x="null" Then Msgbox("o no!","") End If The expected behavior would be that x = null would evaluate to true since this is the way in B4A to check for null values. However. x = "null" evaluates to true! I believe this is a bug.
Vader Well-Known Member Licensed User Longtime User Feb 5, 2013 #2 In a different language I would suggest that a string is not nullable. IE, because you created a string, it cannot be null, rather it would be an empty string. That's my guess.
In a different language I would suggest that a string is not nullable. IE, because you created a string, it cannot be null, rather it would be an empty string. That's my guess.
M melamoud Active Member Licensed User Longtime User Feb 5, 2013 #3 Its not a bug its how it works in b4a String can not be null so it translate the null to "null" If you want thus ability make the type object and translate / cast to string when you need it as string ...
Its not a bug its how it works in b4a String can not be null so it translate the null to "null" If you want thus ability make the type object and translate / cast to string when you need it as string ...
francoisg Active Member Licensed User Longtime User Aug 12, 2015 #4 If you want a simple way to check for any kind of object (strings as well as other classes) you can use the following functions: Sub isNull (o As Object) As Boolean Return ((o = Null) Or (o = "null"))End Sub Sub ifNull (o As Object, default As Object) As Object If isNull(o) Then Return defaultElse Return oEnd IfEnd Sub Last edited: Aug 12, 2015
If you want a simple way to check for any kind of object (strings as well as other classes) you can use the following functions: Sub isNull (o As Object) As Boolean Return ((o = Null) Or (o = "null"))End Sub Sub ifNull (o As Object, default As Object) As Object If isNull(o) Then Return defaultElse Return oEnd IfEnd Sub
R rboeck Well-Known Member Licensed User Longtime User Aug 12, 2015 #5 francoisg said: If you want a simple way to check for any kind of object (strings as well as other classes) you can use the following functions: Sub isNull (o As Object) As Boolean Return ((o = Null) Or (o = "null")) '<------------End Sub Click to expand... Hi, i was looking long time for this type of function; now i tried it, but i get an error in the second row: 'wrong input format' (translated from german); any idea, whats wrong?
francoisg said: If you want a simple way to check for any kind of object (strings as well as other classes) you can use the following functions: Sub isNull (o As Object) As Boolean Return ((o = Null) Or (o = "null")) '<------------End Sub Click to expand... Hi, i was looking long time for this type of function; now i tried it, but i get an error in the second row: 'wrong input format' (translated from german); any idea, whats wrong?
francoisg Active Member Licensed User Longtime User Aug 12, 2015 #6 Hi, I think the code is formatted wrong (remove all spaces in front of the lines, replace with tabs and try again). I had to play with formatting the code in order to display correctly on the web site.
Hi, I think the code is formatted wrong (remove all spaces in front of the lines, replace with tabs and try again). I had to play with formatting the code in order to display correctly on the web site.
R rboeck Well-Known Member Licensed User Longtime User Aug 12, 2015 #7 Hi, that helped; i had to type it myself and the mistakes went away. Strange... Thanks for your help!
Hi, that helped; i had to type it myself and the mistakes went away. Strange... Thanks for your help!
francoisg Active Member Licensed User Longtime User Aug 12, 2015 #8 No problem - glad to be of some help!