PC Review


Reply
Thread Tools Rate Thread

boolean expression

 
 
HS1
Guest
Posts: n/a
 
      18th Oct 2004
Hello

Could you please help for a simple boolean expression

If a is not equal to Null

I tried

If (a != null) Then

This expression does not work

I look at Help but can not find out

Could you please help

Thanks
S.Hoa


 
Reply With Quote
 
 
 
 
Josip Medved
Guest
Posts: n/a
 
      18th Oct 2004
> Could you please help for a simple boolean expression
> If a is not equal to Null
> I tried
> If (a != null) Then



From my point of view it seems that you are trying
to check whether object exists.

Try:
If Not (a Is Nothing) Then

--
Pozdrav,
Josip Medved, MCSD
http://www.jmedved.com
 
Reply With Quote
 
Gerald Hernandez
Guest
Posts: n/a
 
      19th Oct 2004
What sort of "Null" are you looking for?
Database Null?
Object is Nothing?
a <> 0&?

"HS1" <(E-Mail Removed)> wrote in message
news:1098135675.785296@ftpsrv1...
> Hello
>
> Could you please help for a simple boolean expression
>
> If a is not equal to Null
>
> I tried
>
> If (a != null) Then
>
> This expression does not work
>
> I look at Help but can not find out
>
> Could you please help
>
> Thanks
> S.Hoa
>
>



 
Reply With Quote
 
HS1
Guest
Posts: n/a
 
      19th Oct 2004
Thank you
a is a value of a field in a table of a database. I have to check it is null
or not
I have a solution

If Not (a is DBNull.Value) Then

"Gerald Hernandez" <Cablewizard@(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> What sort of "Null" are you looking for?
> Database Null?
> Object is Nothing?
> a <> 0&?
>
> "HS1" <(E-Mail Removed)> wrote in message
> news:1098135675.785296@ftpsrv1...
> > Hello
> >
> > Could you please help for a simple boolean expression
> >
> > If a is not equal to Null
> >
> > I tried
> >
> > If (a != null) Then
> >
> > This expression does not work
> >
> > I look at Help but can not find out
> >
> > Could you please help
> >
> > Thanks
> > S.Hoa
> >
> >

>
>



 
Reply With Quote
 
Gerald Hernandez
Guest
Posts: n/a
 
      19th Oct 2004
you got it, mostly.
i'm not certain if the IS keyword will give you the proper results or not.
this is not a value comparison, but an Object Reference comparison.
it would be safer to use:
If Not (a = DBNull.Value) Then

or use the alternate test using
If Not IsDBNull(a) Then

Gerald

"HS1" <(E-Mail Removed)> wrote in message
news:1098141920.570486@ftpsrv1...
> Thank you
> a is a value of a field in a table of a database. I have to check it is

null
> or not
> I have a solution
>
> If Not (a is DBNull.Value) Then
>
> "Gerald Hernandez" <Cablewizard@(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > What sort of "Null" are you looking for?
> > Database Null?
> > Object is Nothing?
> > a <> 0&?
> >
> > "HS1" <(E-Mail Removed)> wrote in message
> > news:1098135675.785296@ftpsrv1...
> > > Hello
> > >
> > > Could you please help for a simple boolean expression
> > >
> > > If a is not equal to Null
> > >
> > > I tried
> > >
> > > If (a != null) Then
> > >
> > > This expression does not work
> > >
> > > I look at Help but can not find out
> > >
> > > Could you please help
> > >
> > > Thanks
> > > S.Hoa
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
HS1
Guest
Posts: n/a
 
      19th Oct 2004
Thank you

I tried to use =, the compiler get the error

Operator '=' is not defined for types 'System.Object' and 'System.DBNull'.
Use 'Is' operator to compare two reference types.
Therefore, I have to change to "Is"
I use VB.Net 2001

Regards
S.Hoa
"Gerald Hernandez" <Cablewizard@(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> you got it, mostly.
> i'm not certain if the IS keyword will give you the proper results or not.
> this is not a value comparison, but an Object Reference comparison.
> it would be safer to use:
> If Not (a = DBNull.Value) Then
>
> or use the alternate test using
> If Not IsDBNull(a) Then
>
> Gerald
>
> "HS1" <(E-Mail Removed)> wrote in message
> news:1098141920.570486@ftpsrv1...
> > Thank you
> > a is a value of a field in a table of a database. I have to check it is

> null
> > or not
> > I have a solution
> >
> > If Not (a is DBNull.Value) Then
> >
> > "Gerald Hernandez" <Cablewizard@(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> > > What sort of "Null" are you looking for?
> > > Database Null?
> > > Object is Nothing?
> > > a <> 0&?
> > >
> > > "HS1" <(E-Mail Removed)> wrote in message
> > > news:1098135675.785296@ftpsrv1...
> > > > Hello
> > > >
> > > > Could you please help for a simple boolean expression
> > > >
> > > > If a is not equal to Null
> > > >
> > > > I tried
> > > >
> > > > If (a != null) Then
> > > >
> > > > This expression does not work
> > > >
> > > > I look at Help but can not find out
> > > >
> > > > Could you please help
> > > >
> > > > Thanks
> > > > S.Hoa
> > > >
> > > >
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
Gerald Hernandez
Guest
Posts: n/a
 
      19th Oct 2004
What object type is "a"?
You say a database field, but which object.
Is there an a.value property?

I'm still concerned about using IS here.
Take for example that A is a particular object, and System.DBNull is another
object.
The IS operator is more appropriate to determine if "A" is the same object
as DBNull, not the same value.

Gerald

"HS1" <(E-Mail Removed)> wrote in message
news:1098147081.668852@ftpsrv1...
> Thank you
>
> I tried to use =, the compiler get the error
>
> Operator '=' is not defined for types 'System.Object' and 'System.DBNull'.
> Use 'Is' operator to compare two reference types.
> Therefore, I have to change to "Is"
> I use VB.Net 2001
>
> Regards
> S.Hoa
> "Gerald Hernandez" <Cablewizard@(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > you got it, mostly.
> > i'm not certain if the IS keyword will give you the proper results or

not.
> > this is not a value comparison, but an Object Reference comparison.
> > it would be safer to use:
> > If Not (a = DBNull.Value) Then
> >
> > or use the alternate test using
> > If Not IsDBNull(a) Then
> >
> > Gerald
> >
> > "HS1" <(E-Mail Removed)> wrote in message
> > news:1098141920.570486@ftpsrv1...
> > > Thank you
> > > a is a value of a field in a table of a database. I have to check it

is
> > null
> > > or not
> > > I have a solution
> > >
> > > If Not (a is DBNull.Value) Then
> > >
> > > "Gerald Hernandez" <Cablewizard@(E-Mail Removed)> wrote in

message
> > > news:(E-Mail Removed)...
> > > > What sort of "Null" are you looking for?
> > > > Database Null?
> > > > Object is Nothing?
> > > > a <> 0&?
> > > >
> > > > "HS1" <(E-Mail Removed)> wrote in message
> > > > news:1098135675.785296@ftpsrv1...
> > > > > Hello
> > > > >
> > > > > Could you please help for a simple boolean expression
> > > > >
> > > > > If a is not equal to Null
> > > > >
> > > > > I tried
> > > > >
> > > > > If (a != null) Then
> > > > >
> > > > > This expression does not work
> > > > >
> > > > > I look at Help but can not find out
> > > > >
> > > > > Could you please help
> > > > >
> > > > > Thanks
> > > > > S.Hoa
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
HS1
Guest
Posts: n/a
 
      19th Oct 2004
Here is my code

If (DataGrid1.Item(DataGrid1.CurrentCell.RowNumber, 5) Is DBNull.Value) Then

In this code, dataGrid1 presents data for a table. I check the value
(textual type) of current row at column 5 to see that it is Null or not.


"Gerald Hernandez" <Cablewizard@(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> What object type is "a"?
> You say a database field, but which object.
> Is there an a.value property?
>
> I'm still concerned about using IS here.
> Take for example that A is a particular object, and System.DBNull is

another
> object.
> The IS operator is more appropriate to determine if "A" is the same object
> as DBNull, not the same value.
>
> Gerald
>
> "HS1" <(E-Mail Removed)> wrote in message
> news:1098147081.668852@ftpsrv1...
> > Thank you
> >
> > I tried to use =, the compiler get the error
> >
> > Operator '=' is not defined for types 'System.Object' and

'System.DBNull'.
> > Use 'Is' operator to compare two reference types.
> > Therefore, I have to change to "Is"
> > I use VB.Net 2001
> >
> > Regards
> > S.Hoa
> > "Gerald Hernandez" <Cablewizard@(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> > > you got it, mostly.
> > > i'm not certain if the IS keyword will give you the proper results or

> not.
> > > this is not a value comparison, but an Object Reference comparison.
> > > it would be safer to use:
> > > If Not (a = DBNull.Value) Then
> > >
> > > or use the alternate test using
> > > If Not IsDBNull(a) Then
> > >
> > > Gerald
> > >
> > > "HS1" <(E-Mail Removed)> wrote in message
> > > news:1098141920.570486@ftpsrv1...
> > > > Thank you
> > > > a is a value of a field in a table of a database. I have to check it

> is
> > > null
> > > > or not
> > > > I have a solution
> > > >
> > > > If Not (a is DBNull.Value) Then
> > > >
> > > > "Gerald Hernandez" <Cablewizard@(E-Mail Removed)> wrote in

> message
> > > > news:(E-Mail Removed)...
> > > > > What sort of "Null" are you looking for?
> > > > > Database Null?
> > > > > Object is Nothing?
> > > > > a <> 0&?
> > > > >
> > > > > "HS1" <(E-Mail Removed)> wrote in message
> > > > > news:1098135675.785296@ftpsrv1...
> > > > > > Hello
> > > > > >
> > > > > > Could you please help for a simple boolean expression
> > > > > >
> > > > > > If a is not equal to Null
> > > > > >
> > > > > > I tried
> > > > > >
> > > > > > If (a != null) Then
> > > > > >
> > > > > > This expression does not work
> > > > > >
> > > > > > I look at Help but can not find out
> > > > > >
> > > > > > Could you please help
> > > > > >
> > > > > > Thanks
> > > > > > S.Hoa
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
Gerald Hernandez
Guest
Posts: n/a
 
      19th Oct 2004
Ah, I see. Well, if it were me, I would explicitly cast the underlying value
to its appropriate sqltype then check for null. However, I do not know what
kind of underlying data you are dealing with.
You could take the shortcut and use the Convert.IsDBNull which will handle
an expression.
Like so:

If Convert.IsDBNull(DataGrid1.Item(DataGrid1.CurrentCell.RowNumber, 5)) Then

It is possible that the way you are doing it will work fine. But it just
seems dangerous to me.

Gerald

"HS1" <(E-Mail Removed)> wrote in message
news:1098163724.554694@ftpsrv1...
> Here is my code
>
> If (DataGrid1.Item(DataGrid1.CurrentCell.RowNumber, 5) Is DBNull.Value)

Then
>
> In this code, dataGrid1 presents data for a table. I check the value
> (textual type) of current row at column 5 to see that it is Null or not.
>
>
> "Gerald Hernandez" <Cablewizard@(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > What object type is "a"?
> > You say a database field, but which object.
> > Is there an a.value property?
> >
> > I'm still concerned about using IS here.
> > Take for example that A is a particular object, and System.DBNull is

> another
> > object.
> > The IS operator is more appropriate to determine if "A" is the same

object
> > as DBNull, not the same value.
> >
> > Gerald
> >
> > "HS1" <(E-Mail Removed)> wrote in message
> > news:1098147081.668852@ftpsrv1...
> > > Thank you
> > >
> > > I tried to use =, the compiler get the error
> > >
> > > Operator '=' is not defined for types 'System.Object' and

> 'System.DBNull'.
> > > Use 'Is' operator to compare two reference types.
> > > Therefore, I have to change to "Is"
> > > I use VB.Net 2001
> > >
> > > Regards
> > > S.Hoa
> > > "Gerald Hernandez" <Cablewizard@(E-Mail Removed)> wrote in

message
> > > news:(E-Mail Removed)...
> > > > you got it, mostly.
> > > > i'm not certain if the IS keyword will give you the proper results

or
> > not.
> > > > this is not a value comparison, but an Object Reference comparison.
> > > > it would be safer to use:
> > > > If Not (a = DBNull.Value) Then
> > > >
> > > > or use the alternate test using
> > > > If Not IsDBNull(a) Then
> > > >
> > > > Gerald
> > > >
> > > > "HS1" <(E-Mail Removed)> wrote in message
> > > > news:1098141920.570486@ftpsrv1...
> > > > > Thank you
> > > > > a is a value of a field in a table of a database. I have to check

it
> > is
> > > > null
> > > > > or not
> > > > > I have a solution
> > > > >
> > > > > If Not (a is DBNull.Value) Then
> > > > >
> > > > > "Gerald Hernandez" <Cablewizard@(E-Mail Removed)> wrote in

> > message
> > > > > news:(E-Mail Removed)...
> > > > > > What sort of "Null" are you looking for?
> > > > > > Database Null?
> > > > > > Object is Nothing?
> > > > > > a <> 0&?
> > > > > >
> > > > > > "HS1" <(E-Mail Removed)> wrote in message
> > > > > > news:1098135675.785296@ftpsrv1...
> > > > > > > Hello
> > > > > > >
> > > > > > > Could you please help for a simple boolean expression
> > > > > > >
> > > > > > > If a is not equal to Null
> > > > > > >
> > > > > > > I tried
> > > > > > >
> > > > > > > If (a != null) Then
> > > > > > >
> > > > > > > This expression does not work
> > > > > > >
> > > > > > > I look at Help but can not find out
> > > > > > >
> > > > > > > Could you please help
> > > > > > >
> > > > > > > Thanks
> > > > > > > S.Hoa
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
HS1
Guest
Posts: n/a
 
      20th Oct 2004
Thank you

"Gerald Hernandez" <Cablewizard@(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Ah, I see. Well, if it were me, I would explicitly cast the underlying

value
> to its appropriate sqltype then check for null. However, I do not know

what
> kind of underlying data you are dealing with.
> You could take the shortcut and use the Convert.IsDBNull which will handle
> an expression.
> Like so:
>
> If Convert.IsDBNull(DataGrid1.Item(DataGrid1.CurrentCell.RowNumber, 5))

Then
>
> It is possible that the way you are doing it will work fine. But it just
> seems dangerous to me.
>
> Gerald
>
> "HS1" <(E-Mail Removed)> wrote in message
> news:1098163724.554694@ftpsrv1...
> > Here is my code
> >
> > If (DataGrid1.Item(DataGrid1.CurrentCell.RowNumber, 5) Is DBNull.Value)

> Then
> >
> > In this code, dataGrid1 presents data for a table. I check the value
> > (textual type) of current row at column 5 to see that it is Null or not.
> >
> >
> > "Gerald Hernandez" <Cablewizard@(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> > > What object type is "a"?
> > > You say a database field, but which object.
> > > Is there an a.value property?
> > >
> > > I'm still concerned about using IS here.
> > > Take for example that A is a particular object, and System.DBNull is

> > another
> > > object.
> > > The IS operator is more appropriate to determine if "A" is the same

> object
> > > as DBNull, not the same value.
> > >
> > > Gerald
> > >
> > > "HS1" <(E-Mail Removed)> wrote in message
> > > news:1098147081.668852@ftpsrv1...
> > > > Thank you
> > > >
> > > > I tried to use =, the compiler get the error
> > > >
> > > > Operator '=' is not defined for types 'System.Object' and

> > 'System.DBNull'.
> > > > Use 'Is' operator to compare two reference types.
> > > > Therefore, I have to change to "Is"
> > > > I use VB.Net 2001
> > > >
> > > > Regards
> > > > S.Hoa
> > > > "Gerald Hernandez" <Cablewizard@(E-Mail Removed)> wrote in

> message
> > > > news:(E-Mail Removed)...
> > > > > you got it, mostly.
> > > > > i'm not certain if the IS keyword will give you the proper results

> or
> > > not.
> > > > > this is not a value comparison, but an Object Reference

comparison.
> > > > > it would be safer to use:
> > > > > If Not (a = DBNull.Value) Then
> > > > >
> > > > > or use the alternate test using
> > > > > If Not IsDBNull(a) Then
> > > > >
> > > > > Gerald
> > > > >
> > > > > "HS1" <(E-Mail Removed)> wrote in message
> > > > > news:1098141920.570486@ftpsrv1...
> > > > > > Thank you
> > > > > > a is a value of a field in a table of a database. I have to

check
> it
> > > is
> > > > > null
> > > > > > or not
> > > > > > I have a solution
> > > > > >
> > > > > > If Not (a is DBNull.Value) Then
> > > > > >
> > > > > > "Gerald Hernandez" <Cablewizard@(E-Mail Removed)> wrote in
> > > message
> > > > > > news:(E-Mail Removed)...
> > > > > > > What sort of "Null" are you looking for?
> > > > > > > Database Null?
> > > > > > > Object is Nothing?
> > > > > > > a <> 0&?
> > > > > > >
> > > > > > > "HS1" <(E-Mail Removed)> wrote in message
> > > > > > > news:1098135675.785296@ftpsrv1...
> > > > > > > > Hello
> > > > > > > >
> > > > > > > > Could you please help for a simple boolean expression
> > > > > > > >
> > > > > > > > If a is not equal to Null
> > > > > > > >
> > > > > > > > I tried
> > > > > > > >
> > > > > > > > If (a != null) Then
> > > > > > > >
> > > > > > > > This expression does not work
> > > > > > > >
> > > > > > > > I look at Help but can not find out
> > > > > > > >
> > > > > > > > Could you please help
> > > > > > > >
> > > > > > > > Thanks
> > > > > > > > S.Hoa
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Boolean Expression Evaluator Workaholic Microsoft VB .NET 2 6th Aug 2008 11:43 AM
How to simplifying boolean algebra expression? Regardt Microsoft VB .NET 3 12th Apr 2006 09:07 PM
How to simplifying boolean algebra expression? Regardt Microsoft VB .NET 0 11th Apr 2006 09:29 AM
How to simplifying boolean algebra expression? Regardt Microsoft C# .NET 0 11th Apr 2006 09:28 AM
Re: Evaluate Boolean expression Scott M. Microsoft Dot NET Framework 1 27th Sep 2003 05:09 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:30 AM.