The difference between isNull (str), IsEmpty (str) and str =

Source: Internet
Author: User
Tags contains empty expression variable
Difference of 1. IsNull ()


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.





focus on using the IsNull function to determine whether an expression contains a Null value. In some cases, you want the expression to be value True, such as Ifvar=null and Ifvar<>null, but they are usually always False. This is because any expression containing a null itself is null, so the expression evaluates to False.





The following example uses the IsNull function to determine whether a variable contains Null:





Dim MyVar, MyCheck


MyCheck = IsNull (MyVar) ' returns FALSE.


MyVar = null ' is assigned null.


MyCheck = IsNull (MyVar) ' returns TRUE.


MyVar = Empty ' Fu to Empty.


MyCheck = IsNull (MyVar) ' returns FALSE.


2. IsEmpty ()


If the variable is uninitialized 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.





The following example uses the IsEmpty function to determine whether a variable can be initialized:





Dim MyVar, MyCheck


MyCheck = IsEmpty (MyVar) ' returns TRUE.


MyVar = null ' is assigned null.


MyCheck = IsEmpty (MyVar) ' returns FALSE.


MyVar = Empty ' Fu to Empty.


MyCheck = IsEmpty (MyVar) ' returns TRUE.


3. 0 length string ("")


0 length strings are often referred to as empty strings.


str= "", assigning an empty string to a str variable, has been assigned, and is assigned a character





added: You can specify that a field is null in the database design so that if it is no longer assigned to him, the record is null, but when the table is exported, the null record destroys the table's structure, that is, the grid lines in the table will disappear, and many people may A default value is set in the database or an empty string is assigned to the record when processing.














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.