472,119 Members | 963 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,119 software developers and data experts.

vbNullString

Lou
What's the .NET equivalent

Dim strTmp as string
If strTmp=vbNullString

Mar 6 '07 #1
11 8474
>What's the .NET equivalent
>
Dim strTmp as string
If strTmp=vbNullString
If strTmp Is Nothing Then
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Mar 6 '07 #2
String.Empty

Robin S.
-------------------------
"Lou" <lo********@comcast.netwrote in message
news:eb**************@TK2MSFTNGP04.phx.gbl...
What's the .NET equivalent

Dim strTmp as string
If strTmp=vbNullString

Mar 7 '07 #3
String.Empty <="" (or any uninitialized As String variable or parameter in
VB6)
null <=vbNullString (very rare, typically only use in native interops)

"RobinS" <Ro****@NoSpam.yah.nonewrote in message
news:zb******************************@comcast.com. ..
String.Empty

Robin S.
-------------------------
"Lou" <lo********@comcast.netwrote in message
news:eb**************@TK2MSFTNGP04.phx.gbl...
>What's the .NET equivalent

Dim strTmp as string
If strTmp=vbNullString


Mar 7 '07 #4
I don't understand what <=means. Does that mean less than, equal to, and
greater than?

I assumed the OP was asking about converting vbNullString from VB6 to
VB.Net.

Null does not equal vbNullString in VB6. They are two completely different
things.

String.Empty is the replacement for vbNullString.

String.Empty = ""
Nothing = ""
String.Empty = Nothing --True

Note that you can not do this:

Dim str As String
Debug.Print(str)

You *must* assign a value to str before you can display or print it, even
if it's String.Empty. For this reason, many people initialize their strings
like this:

Dim str As String = String.Empty

Robin S.
-----------------------------
"Dr. Jochen Manns" <de***@psimarron.netwrote in message
news:45***********************@news.freenet.de...
String.Empty <="" (or any uninitialized As String variable or parameter
in VB6)
null <=vbNullString (very rare, typically only use in native interops)

"RobinS" <Ro****@NoSpam.yah.nonewrote in message
news:zb******************************@comcast.com. ..
>String.Empty

Robin S.
-------------------------
"Lou" <lo********@comcast.netwrote in message
news:eb**************@TK2MSFTNGP04.phx.gbl...
>>What's the .NET equivalent

Dim strTmp as string
If strTmp=vbNullString



Mar 7 '07 #5
On Tue, 6 Mar 2007 23:23:32 -0800, RobinS wrote:
I don't understand what <=means. Does that mean less than, equal to, and
greater than?

I assumed the OP was asking about converting vbNullString from VB6 to
VB.Net.

Null does not equal vbNullString in VB6. They are two completely different
things.

String.Empty is the replacement for vbNullString.

String.Empty = ""
Nothing = ""
String.Empty = Nothing --True

Note that you can not do this:

Dim str As String
Debug.Print(str)

You *must* assign a value to str before you can display or print it, even
if it's String.Empty. For this reason, many people initialize their strings
like this:

Dim str As String = String.Empty

Robin S.
Hey Robin,

vbNullString is not equal to String.Empty. 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
http://bytes.thinkersroom.com
Mar 7 '07 #6
"Rad [Visual C# MVP]" <no****@nospam.comwrote in message
news:1n***************@thinkersroom.com...
On Tue, 6 Mar 2007 23:23:32 -0800, RobinS wrote:
>I don't understand what <=means. Does that mean less than, equal to,
and
greater than?

I assumed the OP was asking about converting vbNullString from VB6 to
VB.Net.

Null does not equal vbNullString in VB6. They are two completely
different
things.

String.Empty is the replacement for vbNullString.

String.Empty = ""
Nothing = ""
String.Empty = Nothing --True

Note that you can not do this:

Dim str As String
Debug.Print(str)

You *must* assign a value to str before you can display or print it,
even
if it's String.Empty. For this reason, many people initialize their
strings
like this:

Dim str As String = String.Empty

Robin S.

Hey Robin,

vbNullString is not equal to String.Empty. 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
http://bytes.thinkersroom.com
So here's my algebraic thinking.

In vb6: ?vbNullString = "" --true
In VB.Net: ?String.Empty = "" --true
(?Nothing = "" --true, so this is weird)

Algebraically speaking, if (a = b) and (b = c) then (a = c).

Therefore, if (vbNullString = '") and ("" = String.Empty),
then (vbNullString = String.Empty).

That's my theory!

Unless algebra doesn't hold true for .Net programming, in which I'm
screwed.

Robin S.
Mar 8 '07 #7
Being a VB developer (since vb3), I hereby confirm that vbNullString is
equivalent to Nothing. And a "nulled" variable is equivalent to
String.Empty

Here's an ASP.NET scenario:

Page 1 submits FormField1 to Page 2. FormField1 is an empty textbox. Page
1 posts to Page 2.
Page 2 instantiates a variable, varField1.
varField1 = Request.Form("FormField1") results in varField1 = String.Empty
BUT
varField1 = Request.Form("FormField2") .. which does not exist... then
varField1 = Nothing (not an empty string, but just no value assigned).

I have run across this conundrum several times in my career, and it always
amazes me how C-based developers don't see the difference =o)

- nasser

"Rad [Visual C# MVP]" <no****@nospam.comwrote in message
news:1n***************@thinkersroom.com...
On Tue, 6 Mar 2007 23:23:32 -0800, RobinS wrote:
>I don't understand what <=means. Does that mean less than, equal to,
and
greater than?

I assumed the OP was asking about converting vbNullString from VB6 to
VB.Net.

Null does not equal vbNullString in VB6. They are two completely
different
things.

String.Empty is the replacement for vbNullString.

String.Empty = ""
Nothing = ""
String.Empty = Nothing --True

Note that you can not do this:

Dim str As String
Debug.Print(str)

You *must* assign a value to str before you can display or print it, even
if it's String.Empty. For this reason, many people initialize their
strings
like this:

Dim str As String = String.Empty

Robin S.

Hey Robin,

vbNullString is not equal to String.Empty. 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
http://bytes.thinkersroom.com
Mar 8 '07 #8
"RobinS" posted...
: So here's my algebraic thinking.
:
: In vb6: ?vbNullString = "" --true
: In VB.Net: ?String.Empty = "" --true
: (?Nothing = "" --true, so this is weird)
:
: Algebraically speaking, if (a = b) and (b = c) then (a = c).
:
: [...]
:
: Unless algebra doesn't hold true for .Net programming, in which
: I'm screwed.

Golly Gee Batman!

Not True <False!
Not False <True!

If (a = True), (b = False), (c = True) Then
a + b = c and
b + c = c
b + c = a

Algebra does not apply! What shall we call the Screwy one,
Batman?!?

Screwballs, Robin!

--
Jim Carlock
Post replies to the group.
Mar 8 '07 #9
"Jim Carlock" <anonymous@localhostwrote in message
news:ub*************@TK2MSFTNGP04.phx.gbl...
"RobinS" posted...
: So here's my algebraic thinking.
:
: In vb6: ?vbNullString = "" --true
: In VB.Net: ?String.Empty = "" --true
: (?Nothing = "" --true, so this is weird)
:
: Algebraically speaking, if (a = b) and (b = c) then (a = c).
:
: [...]
:
: Unless algebra doesn't hold true for .Net programming, in which
: I'm screwed.

Golly Gee Batman!

Not True <False!
Not False <True!

If (a = True), (b = False), (c = True) Then
a + b = c and
b + c = c
b + c = a

Algebra does not apply! What shall we call the Screwy one,
Batman?!?

Screwballs, Robin!

--
Jim Carlock
Post replies to the group.

-----------------------------------

Holy Pythagorean Theorem, Batman! It's a nutcase!

Robin S.
Mar 8 '07 #10
On Wed, 7 Mar 2007 17:36:28 -0800, RobinS wrote:
"Rad [Visual C# MVP]" <no****@nospam.comwrote in message
news:1n***************@thinkersroom.com...
>On Tue, 6 Mar 2007 23:23:32 -0800, RobinS wrote:
>>I don't understand what <=means. Does that mean less than, equal to,
and
greater than?

I assumed the OP was asking about converting vbNullString from VB6 to
VB.Net.

Null does not equal vbNullString in VB6. They are two completely
different
things.

String.Empty is the replacement for vbNullString.

String.Empty = ""
Nothing = ""
String.Empty = Nothing --True

Note that you can not do this:

Dim str As String
Debug.Print(str)

You *must* assign a value to str before you can display or print it,
even
if it's String.Empty. For this reason, many people initialize their
strings
like this:

Dim str As String = String.Empty

Robin S.

Hey Robin,

vbNullString is not equal to String.Empty. 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
http://bytes.thinkersroom.com

So here's my algebraic thinking.

In vb6: ?vbNullString = "" --true
In VB.Net: ?String.Empty = "" --true
(?Nothing = "" --true, so this is weird)

Algebraically speaking, if (a = b) and (b = c) then (a = c).

Therefore, if (vbNullString = '") and ("" = String.Empty),
then (vbNullString = String.Empty).

That's my theory!

Unless algebra doesn't hold true for .Net programming, in which I'm
screwed.

Robin S.
Looks like MSDN is a bit of a goof. Much as it says string.Empty <"" A
quick console application shows otherwise

Console.WriteLine(String.Empty="") -True
Console.WriteLine(string.Empty=nothing) -True
--
Bits.Bytes
http://bytes.thinkersroom.com
Mar 8 '07 #11

"Rad [Visual C# MVP]" <no****@nospam.comwrote in message
news:1v***************@thinkersroom.com...
On Wed, 7 Mar 2007 17:36:28 -0800, RobinS wrote:
>"Rad [Visual C# MVP]" <no****@nospam.comwrote in message
news:1n***************@thinkersroom.com...
>>On Tue, 6 Mar 2007 23:23:32 -0800, RobinS wrote:

I don't understand what <=means. Does that mean less than, equal to,
and
greater than?

I assumed the OP was asking about converting vbNullString from VB6 to
VB.Net.

Null does not equal vbNullString in VB6. They are two completely
different
things.

String.Empty is the replacement for vbNullString.

String.Empty = ""
Nothing = ""
String.Empty = Nothing --True

Note that you can not do this:

Dim str As String
Debug.Print(str)

You *must* assign a value to str before you can display or print it,
even
if it's String.Empty. For this reason, many people initialize their
strings
like this:

Dim str As String = String.Empty

Robin S.

Hey Robin,

vbNullString is not equal to String.Empty. 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
http://bytes.thinkersroom.com

So here's my algebraic thinking.

In vb6: ?vbNullString = "" --true
In VB.Net: ?String.Empty = "" --true
(?Nothing = "" --true, so this is weird)

Algebraically speaking, if (a = b) and (b = c) then (a = c).

Therefore, if (vbNullString = '") and ("" = String.Empty),
then (vbNullString = String.Empty).

That's my theory!

Unless algebra doesn't hold true for .Net programming, in which I'm
screwed.

Robin S.

Looks like MSDN is a bit of a goof. Much as it says string.Empty <"" A
quick console application shows otherwise

Console.WriteLine(String.Empty="") -True
Console.WriteLine(string.Empty=nothing) -True
--
Bits.Bytes
http://bytes.thinkersroom.com
Algebra rules!

Robin S.
Mar 9 '07 #12

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

43 posts views Thread by ZillionDollarSadist | last post: by
6 posts views Thread by Tark Siala | last post: by
13 posts views Thread by Lou | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.