Help: Can't use "Not"???  
Author Message
ValerieReid





PostPosted: Wed Sep 03 13:42:53 CDT 2003 Top

Visual C#.Net >> Help: Can't use "Not"??? I want to set the enabled property of a text box based on if a checkbox is
checked or not. This works....

txtPort.Enabled = ckDefaultPort.Checked;

But, I want the enabled property to be the opposite of the checked value.
Why doesn't this work?

txtPort.Enabled = Not ckDefaultPort.Checked;

It keeps telling my "; expected".

Thanks.

DotNet156  
 
 
Paul





PostPosted: Wed Sep 03 13:42:53 CDT 2003 Top

Visual C#.Net >> Help: Can't use "Not"??? "VB Programmer" <EMail@HideDomain.com> wrote:

> txtPort.Enabled = Not ckDefaultPort.Checked;
> It keeps telling my "; expected".

Well, you can't write VB code in C#.

txtPort.Enabled = !ckDefaultPort.Checked;

P.

--
www.CL4.org


 
 
Mickey





PostPosted: Wed Sep 03 13:41:43 CDT 2003 Top

Visual C#.Net >> Help: Can't use "Not"??? You're not using VB, so you can't use Visual Basic syntax.

try:
txtPort.Enabled = !ckDefaultPort.Checked;
or

txtPort.Enabled = (ckDefaultPort.Checked == false);

--
Mickey Williams
Author, "Microsoft Visual C# .NET Core Reference", MS Press
www.servergeek.com


"VB Programmer" <EMail@HideDomain.com> wrote in message
news:EMail@HideDomain.com...
> I want to set the enabled property of a text box based on if a checkbox is
> checked or not. This works....
>
> txtPort.Enabled = ckDefaultPort.Checked;
>
> But, I want the enabled property to be the opposite of the checked value.
> Why doesn't this work?
>
> txtPort.Enabled = Not ckDefaultPort.Checked;
>
> It keeps telling my "; expected".
>
> Thanks.
>
>


 
 
VB





PostPosted: Wed Sep 03 13:44:11 CDT 2003 Top

Visual C#.Net >> Help: Can't use "Not"??? Sorry, I know, I have to use "!"

"VB Programmer" <EMail@HideDomain.com> wrote in message
news:EMail@HideDomain.com...
> I want to set the enabled property of a text box based on if a checkbox is
> checked or not. This works....
>
> txtPort.Enabled = ckDefaultPort.Checked;
>
> But, I want the enabled property to be the opposite of the checked value.
> Why doesn't this work?
>
> txtPort.Enabled = Not ckDefaultPort.Checked;
>
> It keeps telling my "; expected".
>
> Thanks.
>
>


 
 
Sunny





PostPosted: Wed Sep 03 13:46:05 CDT 2003 Top

Visual C#.Net >> Help: Can't use "Not"??? In C# there is no Not, you have to use "!" operator:

txtPort.Enabled = !ckDefaultPort.Checked;

"VB Programmer" <EMail@HideDomain.com> wrote in message
news:EMail@HideDomain.com...
> I want to set the enabled property of a text box based on if a checkbox is
> checked or not. This works....
>
> txtPort.Enabled = ckDefaultPort.Checked;
>
> But, I want the enabled property to be the opposite of the checked value.
> Why doesn't this work?
>
> txtPort.Enabled = Not ckDefaultPort.Checked;
>
> It keeps telling my "; expected".
>
> Thanks.
>
>


 
 
Joshua





PostPosted: Wed Sep 03 13:55:01 CDT 2003 Top

Visual C#.Net >> Help: Can't use "Not"??? txtPort.Enabled = !ckDefaultPort.Checked;

"VB Programmer" <EMail@HideDomain.com> wrote in message
news:EMail@HideDomain.com...
> I want to set the enabled property of a text box based on if a checkbox is
> checked or not. This works....
>
> txtPort.Enabled = ckDefaultPort.Checked;
>
> But, I want the enabled property to be the opposite of the checked value.
> Why doesn't this work?
>
> txtPort.Enabled = Not ckDefaultPort.Checked;
>
> It keeps telling my "; expected".
>
> Thanks.
>
>