Just wondering if anyone knows of a way to implement a Typed Nullable Type like NullableOfInteger in VB6? (I’m trying to avoid using variants)
You can easily create a custom class NullableOfInteger and use its uninitialized state to indicate a Null state but this comes with the obvious disadvantages.
Beyond that I can’t really think of any other ways? My gut tells me there would be no good way.
VB6 doesn’t have the operator overloading or custom implicit casting that nullable types in VB.NET utilize. You really can’t do it any better than variant.
An alternative is to choose a specific value and consistently treat that value as null. In .NET 1.0 days people used to use
int.MinValue. I don’t know what the VB6 equivalent is but I’m sure there’s something. This works and is not nearly as bad as it sounds (but nullable types are better).