Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the difference between Empty and Null in vbs

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly explains "what is the difference between Empty and Null in vbs". The content in the article is simple and clear, easy to learn and understand. Please follow the editor's train of thought to study and learn "what is the difference between Empty and Null in vbs".

The empty keyword refers to the value of an uninitialized variable, unlike NULL

The NULL keyword is used to indicate that the variable contains invalid data, unlike empty

Example:

Dim p

'at this time

Isempty (p) is true

IsNull (p) is null

For example, if you read out a field of a record in the database, the PPP value is null, and the field has no data.

P=rs ("ppp")

At this point isNull (p) = true

Let's talk about something that is easy to blur (which may also be difficult for everyone to understand)

Vbs allows variable assignment without declaring variables when there is no option explicit

If there is no dim p

P = "aaa" will implicitly define the variable p when it first meets, which may be puzzling here.

-

One is:

Dim p

Isempty (p) is true

IsNull (p) is false

Show defined variables

-

Second:

Isempty (p) is true

IsNull (p) is false

The program is not allowed to continue to run unless option explicit is forcibly declared

Implicit definition of variables, implicit definition occurs in the first use of variables

When there is no explicit dim p, the actual operating mechanism will be the first time p is used

Isempty (p)

Search function scope, no definition, and then search global scope, no definition! Ok defines dim p)

And then

Isempty (p)

Actually it is.

Isempty (p)

->

(P?-> no dim p-> dim p)

->

IsEmpty (p)

IsNull (p)

So the processing result of the program isNull (p) = = false instead of true

Null is not easy to catch it, how to judge him?

-

P=null

IsNull (p) = true

Now I wonder why p is initialized and why isNull (p) = true, because it happens when null is assigned to p and p variables are used to represent data that does not exist.

More specifically, it is represented by "something with nothing" at this time.

-

So when will isnull be true?

For example, when a database object data call occurs, the column of the database allows null

What's worse is! The Chinese translation null in SQL server2000 is also called "null value" at this time, confused, all the reasons occur in translation, so it is necessary to use more to understand the real difference of empty,null, do not confuse in the translation of Chinese characters, and there are some differences in the treatment of null empty in different languages)

"vacuum" can be called empty

And null doesn't even have a vacuum.

This in itself is two very abstract concepts!

Give another example to deepen the understanding of Null and Empty

There are two tables below, table A has three records, all have actual data, table B has two records, and the second record "B field 1"

Is an empty character; the aID bID of table An and table B are auto-numbered fields, and Null is not allowed to be filled in.

Table A | Table B

_ | _ _

AID A field | bID B field

1 AAA1 | 1 BBB1

2 AAA2 | 2

3 AAA3 |

_ _ _

The result of A left outer Join B qualified by aID and bID

(select * From A left join B on A.aID=B.bID)

_ _ _

AID A field 1 bID B field 1

1 AAA1 1 BBB1

2 AAA2 2

2 AAA2 3 Null

_ _ _

Analyze the above results:

A left join B forces table B to match the output recordset of table A, regardless of whether the bid of table B exists in table A.

In this way, the bid=1 bid=2 of table B matches the aID=1 aID=2 of A, so the corresponding data of bID appears in the result set as is!

While the record of the record number bID=3 does not exist in the B table, it requires that the match be forced into the joint result set. At this time, based on the condition of on A.aid=B.bID, the B.bid=A.aID appears in the joint output result column of the B table, while the "B field 1"

The third record does not exist, so the federated result set can only be data identified as null-- / / non-existent / /

The empty characters of record 2 continue to be filled with empty word symbols.

Through this example, we can see the real meaning of using null.

An empty character in the data is equivalent to an empty seat.

And null doesn't even have this empty seat.

Another example:

1:AAA 2: BBB 3: 4:DD'3: the place is Empty

1:AAA 2:BBB 4:DD 'doesn't even have the seat number 3:. There's a null.

Thank you for your reading, the above is the content of "what is the difference between Empty and Null in vbs". After the study of this article, I believe you have a deeper understanding of what is the difference between Empty and Null in vbs. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report