>
As given, I'm not sure you can do this comparison.
Can a String hold a "database-y" null value? (As opposed to a proper
Nothing?)
>
Well anyway, an Object can, so
>
Dim o as Object _
= PotentiallyNull ValueFromDB()
>
If o Is System.DBNull.V alue Then
. . .
>
HTH,
Phill W.
vbNullString doesn't represent a database null, it's just an empty string.
On Tue, 06 Mar 2007 21:20:01 +0100, Göran Andersson wrote:
Lou wrote:
>What's the .NET equivalent
>>
>Dim strTmp as string
>If strTmp=vbNullSt ring
>>
>Posted this earlier in the wrong Newsgroup.
>>
>
String.Empty
Not true. String.Empty equates to "", the zero length string. The MSDN
documentation specifically states that vbNullString is not the same as a
zero-length string.
I think the closest thing would be nothing
--
Bits.Bytes
On Tue, 06 Mar 2007 21:20:01 +0100, Göran Andersson wrote:
>
>Lou wrote:
>>What's the .NET equivalent
>>>
>>Dim strTmp as string
>>If strTmp=vbNullSt ring
>>>
>>Posted this earlier in the wrong Newsgroup.
>>>
>String.Empty
>
Not true. String.Empty equates to "", the zero length string. The MSDN
documentation specifically states that vbNullString is not the same as a
zero-length string.
>
I think the closest thing would be nothing
You are right. There seems to be a lot of confusion out there. I found
advice to use vbNullString instead of "", but then that is not good
advice at all, as they have completely different uses.
I checked the implementation of vbNullString in the
Microsoft.Visua lBasic library, and it's a constant string with the value
Nothing, so it's exactly the same as Nothing.
>vbNullString doesn't represent a database null, it's just an empty
>string.
>
It's a string pointer with value 0 in VB6, primarily used when calling
Win32 API functions.
>
Yes, you are right.
I searched for how vbNullString was used, and came to the conclusion
that it was an empty string, but most of what I found appearently was
written by people more confused than I was...
a pointer to computer memory address zero
or (as I assume)
a not yet set pointer (represented in VB.Net by the keyword Nothing)
<snip>
Which, AFAIK, happen to be exactly the same thing.
A pointer to the computer memory address 0 has the value of 0 (a
pointer, I suppose you know, *is* the value it points to), and a "not
yet set pointer" is exactly this, a reference value which was set to 0
-- upon initialization by the VB compiler generated code -- to mean
what other languages call "Null" and we call Nothing.
It became a convention to treat pointers (our "reference values") that
reference the special (and invalid) address 0 as non-initialized,
which is not exactly true: the pointer *was* initialized but to a
value known to be unusable.
Historically VB was one of the languages that always enforced this
notion, initializing the stack area to 0 and thus setting local
variables to a default, known value: 0, false, Nothing, etc. If
someone thinks this is not a big deal, compare it to Delphi, which
doesn't do this and requires you to initialize each and every local
variable before use (which is a major pain, and after you've done that
a zillion times you start looking for the compiler switch that
initializes the variables for you -- but there's none). C and C++ do
the same, but most compilers only warn you of the non-initilizion,
while others don't even bother to, so the programmer can happily use
values set to whatever was in the variable address at run time and
become appalled when things go awry with his/her code...
Uh, I guess I'm heavilly drifting to OT land now...
Comment