Solved

Not understand NULL

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

758 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

22 Experts available now in Live!

Get 1:1 Help Now