ASP empty string, IsNull, IsEmpty Difference Analysis _ Application Tips

Source: Internet
Author: User
Description: Set Aa=server.createobject ("DDD")
ISNULL description pointer is null, pointer to an invalid position, that is, the object does not exist,
IsEmpty Note the pointer points to a valid location, but the value is null

1, empty string
Cases:
Copy Code code as follows:

A) Dim strtmp
Response.Write (strtmp= "") ' returns True
b) Response.Write (str= "") ' returns True
c) Dim strtmp
Strtmp= ""
Response.Write (strtmp= "") ' returns True

These lines of code indicate whether the ASP is a variable that has not been declared or a variable that makes a declaration but does not assign a value that is considered an empty string or is called a 0-length string.

2, IsEmpty ()
If the variable is not initialized or explicitly set to Empty, the function IsEmpty returns True;
Otherwise, the function returns FALSE. If expression contains more than one variable, the total returns FALSE.
Cases:
Copy Code code as follows:

A) Dim strtmp
Response.Write (IsEmpty (strtmp)) ' Returns True
b) Dim strtmp
strtmp = Null
Response.Write (IsEmpty (strtmp)) ' Return flase
c) Dim strtmp
strtmp = Empty
Response.Write (IsEmpty (strtmp)) ' Returns True
d) Dim strtmp
strtmp = ""
Response.Write (IsEmpty (strtmp)) ' Return flase

3, IsNull ()
A Null value indicates that the variable does not contain valid data. Null differs from Empty, which indicates that the variable was uninitialized. Null is also different from a 0-length string (""), and a 0-length string often refers to an empty string.
You can use the IsNull function to determine whether an expression contains a Null value.
Cases:
Copy Code code as follows:

a) Dim strtmp
Response.Write (IsNull (strtmp)) ' Returns False
B ' Response. Write (IsNull (strtmp)) ' Return False note here strtmp is an undeclared variable
a) Dim strtmp
strtmp = Null
Response.Write (s trtmp)) ' returns True
a) Dim strtmp
strtmp = Empty
Response.Write (IsNull (strtmp)) ' Returns False
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.