String is not null, empty, or empty string

后端 未结 6 813
礼貌的吻别
礼貌的吻别 2021-01-04 07:18

What is the quickest and easiest way (in Classic ASP) to check if a string has some string (that has a length greater than 0) i.e. NOT \"Null\", \"Nothing\", \"Empty\", or \

6条回答
  •  -上瘾入骨i
    2021-01-04 08:00

    Here's a one-liner that dodges all the trouble with Null by concatenating the value with an empty string. It works for Null, Empty, "", and, of course, strings with actual length! The only one it doesn't (nor shouldn't) work for is Nothing, because that's for object variables, of which a string is not.

    isNullOrEmpty = (Len("" & myString) = 0)
    

提交回复
热议问题