Home All Groups Group Topic Archive Search About
Author
28 Aug 2006 2:06 PM
John
Hi

I am confused over how to check for nulls (Nothing in vb.net?). For instance
I am trying to create user in my vb.net/asp.net app as below;

Dim newUser As MembershipUser = Membership.CreateUser(Username, Password,
Email, passwordQuestion, passwordAnswer, True, status)
If (newUser = Nothing) Then

But I get an "Operator '=' is not defined for types
'System.Web.Security.MembershipUser' and
'System.Web.Security.MembershipUser'. " error on the second line above. What
is the correct method to check for nothing in vb.net?

Thanks

Regards

Author
28 Aug 2006 2:07 PM
Van den Driessche Willy
Use the "Is" operator
If (newUser is Nothing) Then

or the related (VS2005)
If (newUser isNot Nothing) Then


Show quoteHide quote
"John" <John@nospam.infovis.co.uk> wrote in message
news:OY0xnsqyGHA.772@TK2MSFTNGP05.phx.gbl...
> Hi
>
> I am confused over how to check for nulls (Nothing in vb.net?). For
instance
> I am trying to create user in my vb.net/asp.net app as below;
>
> Dim newUser As MembershipUser = Membership.CreateUser(Username, Password,
> Email, passwordQuestion, passwordAnswer, True, status)
> If (newUser = Nothing) Then
>
> But I get an "Operator '=' is not defined for types
> 'System.Web.Security.MembershipUser' and
> 'System.Web.Security.MembershipUser'. " error on the second line above.
What
> is the correct method to check for nothing in vb.net?
>
> Thanks
>
> Regards
>
>
Author
28 Aug 2006 2:13 PM
Karl Seguin [MVP]
use the "is" keyword in vb.net

if user is nothing then


Karl

Show quoteHide quote
"John" <John@nospam.infovis.co.uk> wrote in message
news:OY0xnsqyGHA.772@TK2MSFTNGP05.phx.gbl...
> Hi
>
> I am confused over how to check for nulls (Nothing in vb.net?). For
> instance I am trying to create user in my vb.net/asp.net app as below;
>
> Dim newUser As MembershipUser = Membership.CreateUser(Username, Password,
> Email, passwordQuestion, passwordAnswer, True, status)
> If (newUser = Nothing) Then
>
> But I get an "Operator '=' is not defined for types
> 'System.Web.Security.MembershipUser' and
> 'System.Web.Security.MembershipUser'. " error on the second line above.
> What is the correct method to check for nothing in vb.net?
>
> Thanks
>
> Regards
>
>