Very basic Null value question

BlueIshDan

☠
Local time
Today, 13:40
Joined
May 15, 2014
Messages
1,122
Code:
Public Function ValidString(str) As Boolean
       ValidString = (Len(str + vbNullString) > 0)
End Function

parameter str has value = Null

why is Len(str + vbNullString) returning Null
I've used this method for a while now and I've never had issues with Null until now...

This produceses runtime error 92.
 
Have you tried "&" instead of "+"? "+" propagates Nulls, "&" does not.
 
& is used for concatenation + is used for Null propagation. So,
Code:
Null & vbNullString = vbNullString
Null + vbNullString = Null
That is why you get the error.
 
Omf that's it. I've been working in python and javascript a lot recently lol. I can't believe that slipped my mind! Thank you so much pbaldy and paul :D
 
Oh dear Paul it's a good job col doesn't read the techie stuff, what's with the ' , is your other job a grocer? :D

Brian
 

Users who are viewing this thread

Back
Top Bottom