[thelist] ASP.NET Weird If-Then thing with Is Nothing

Chris at globet.com Chris at globet.com
Thu Aug 11 11:23:29 CDT 2005


Casey

> if not sdrDocs("Address2") is nothing then
>    lblDocMainAddress.Text = lblDocMainAddress.Text & "<br>" & 
> sdrDocs("Address2")& "<br>"
> end if
> 
> Okay this should be an easy one.  The weird thing is, both of 
> the <br>'s get included regardless if Address2 is null or 
> not.  I thought EVERYTHING between the "then" and "end if" 
> were conditional... right?

I don't know about VB.NET, but in VBScript Nothing and Null are two
different things. Have you tried something along the following lines:

strAddress2 = sdrDocs("Address2")

bIsBadValue = IsNull(strAddress2)
bIsBadValue = bIsBadValue Or (strAddress2 Is Nothing)
bIsBadValue = bIsBadValue Or (strAddress2 = "")

if not bIsBadValue then
    lblDocMainAddress.Text = lblDocMainAddress.Text & "<br>" &
sdrDocs("Address2")& "<br>"
end if

Chris Marsh
Web Developer
http://www.globet.com/
Tel: +44 20 8246 4804 Ext 828
Fax: +44 20 8246 4808

Any opinions expressed in this email are those of the individual and not
necessarily the Company. This message is intended for the use of the
individual or entity to which it is addressed and may contain
information that is confidential and privileged and exempt from
disclosure under applicable law. If the reader of this message is not
the intended recipient, you are hereby notified that any dissemination,
distribution, or copying of this communication is strictly prohibited.
If you have received this communication in error, please contact the
sender immediately and delete it from your system. 


More information about the thelist mailing list