Solved

Not understand NULL

Posted on 1999-01-14
5
163 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…

803 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