null empty "" 0 ......

razaqad

Raza
Local time
Tomorrow, 00:30
Joined
Mar 12, 2006
Messages
83
what is the difference between null , "" , empty, nothing etc.

how to reset variables (string, integers, dates etc)

eg:

dim abc as string

abc = "This is a string variable"

abc = ?? empty or "" , null , or what
 
It's a little confusing... But you can think of it this way: A string value in an Access table can be one of three types.

1. Length (my term), manifested many ways: "hello", "999-99-999Y", "Larry66", "etc"

2. Zero Length, manifested one way: ""

3. Null, manifested one way:

Null is neither a zero length string (ZLS) nor a string with length. Null is a type (or state, if you like) of a value. You can effectively stop Access tables from using Null by setting a field's Allow Zero Length and Required properties to Yes.

Regards,
Tim

PS. I'll let somebody else tackle objects and Nothing.
 
so what are the values for different types of variables which have not yet been initialized
 
Null is Access way of saying "I have no idea what this is"

so if you add some thing to a Null you still get Null, if you add to an empty string or 0 you get an answer

Null + "ABC" = Null
"" + "ABC" = "ABC"

you cant compare to a Null either because Access has no idea what it is.

if myVar = Null Then < this will give an error
if isNull(myVar) Then <Correct way to test for Nulls

Nothing works with the Set command and free's up memory

Set rst = CurrentDb.OpenRecordset(strSQL) < Allocates memory

Set rst = Nothing < frees it up agin

Hope that makes some sort of sense :)

Peter
 
razaqad said:
so what are the values for different types of variables which have not yet been initialized

You can use a stop statement (or a breakpoint) as well as the Locals Window to find out (see attached pic).

Regards,
Tim
 

Attachments

  • getValues.JPG
    getValues.JPG
    24.2 KB · Views: 184

Users who are viewing this thread

Back
Top Bottom