Solved

Not understand NULL

Posted on 1999-01-14
5
160 Views
Last Modified: 2010-05-03
1. A help file said that var1 in IsNull(var1) should be a Variant type variable, but in an exmaple var1 is a textbox name.  var1 can be what type?
2. If var1 is a txtbox name, or other object name, what means by IsNull(var1) = True?
3. Can we assign Null to a variable other than the ones of Variant type?
0
Comment
Question by:learn
  • 2
  • 2
5 Comments
 
LVL 3

Accepted Solution

by:
traygreen earned 50 total points
ID: 1456303
1) VB will typecast the variable to Variant - so string etc are valid parameters
2)if you pass the name in as parameter var1 and it is null then will return true
3)Typically no.  You have to assign an empty string to a string not null, nor can you assign it to numeric types
0
 
LVL 10

Expert Comment

by:caraf_g
ID: 1456304
1 the reason why the parameter in IsNull is a variant is because you can put in any type of variable - string, integer etcetera.
2 hard to say - if, for example, the data is retrieved from a database using SQL, it means that the contents of the field in the database was NULL.
3 No
0
 
LVL 3

Expert Comment

by:traygreen
ID: 1456305
Sorry the answer #2 is incorrect - It will return false
Basically Null is returned when a variable pointer does not address memory.
In other languages you would use it (or nil) to destroy the address link between a variable and it's memory location.  
0
 

Author Comment

by:learn
ID: 1456306
So you, experts, said
a) we can put any type as the parameter in IsNull(), VB take care of turnning them to Variant;
b) we can not assign Null to any type except Variant.
am I right?

I remember I wrote a code
    Dim s As String
    Print IsNull(s)
and got error message: using Null incurrect....
I will check this code again later.

Thanks a lot
0
 

Author Comment

by:learn
ID: 1456307
Sorry, we should not get any error in the last code.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
VBA color chart bars 12 78
How to measure sizes and angles in scanned images ? 3 54
Passing a Text Box name to a Sub 6 78
Set email body to html using vbscript 6 28
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now