The many names of(This is an archeological work of mine, as I started programming in VB6.)
Visual Basic 1.0's default data type was Integer.
It meant that if one declared a variable without an explicit data type, its assigned one was Integer.
Visual Basic 2.0 introduced the Variant data type and it became the new default one.
Null and Nothing made their first appearances in that version, too.
Although the Empty keyword/constant was introduced only in VB 3.0 (Object was also introduced in 3.0), I suppose its value was known since 2.0's times.
It is the default value a Variant variable has until it is explicitly assigned a different one.
So far we have three different ways of having no-values: Empty, Null, and Nothing.
Empty is the most friendly of them. If you add it to a number, it acts as it was a zero.
If you concatenate it to another piece of string, Empty morphs into an empty string.
If you assign Empty to a Date variable, it gets a #0:00:00 AM# value.
Gophers would call it the "zero value."
Nulls come from interoperating with databases. If you try to add it to a number, you get Null back.
If you try to assign it to a Date, you get an error, 94 - Invalid use of Null.
(If you concatenate it to a string, you get that string untouched, though.)
Then there's Nothing. It is the default value for an Object variable.
Under the hood, Nothing is only a null pointer to an IUnknown variable, so its layout in memory is very different from the Variant's one.
(Internally Variant is a C-style union. It can hold anything.)
But we are not done yet. When a procedure has an optional parameter, it may not be provided when calling the procedure.
For example, the CurDir$ function has the following signature:
Function CurDir$(Optional ByRef Drive As Variant) As String
It can be called like this:
Folder = CurDir$
How do we know inside the function that the argument was not there?
We use the IsMissing function. When not provided, VB passes a special value in the Variant optional parameter that can be tested using the IsMissing function.
Meanwhile, in the .NET land...When Microsoft leaped to .NET, its engineers banned the Variant data type and conflated it with Object.
They also phased out the Empty keyword and merged its functionality to the Nothing keyword.
This led to some situations where VB.NET is not able to detect that Nothing is... well, Nothing and not the zero value.
Also, in the .NET world, there is no IsMissing function anymore. Every optional parameter is required to have an explicit default value in the procedure signature.
If there's no "invalid" value one can choose to be the default, then hilarity ensues.
Back to businessSo, there you have it. Four different ways to state that something was not there.
Next week we'll return to our transpiler series and start dealing with the procedure area.