ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   macro codes (https://www.excelbanter.com/excel-discussion-misc-queries/158773-macro-codes.html)

peyman

macro codes
 
hi,
can anybody explain to me what does "not" do in the following code:

With Sheets("Sheet1").OptionButton1 'code name for the button
.Value = Not .Value
End With
thanks

Dave Peterson

macro codes
 
The optionbutton's value can be true or false.

Not true = false
not false = true

The code toggles the optionbutton from checked to unchecked or vice versa.



peyman wrote:

hi,
can anybody explain to me what does "not" do in the following code:

With Sheets("Sheet1").OptionButton1 'code name for the button
.Value = Not .Value
End With
thanks


--

Dave Peterson

Chip Pearson

macro codes
 
The "Not" operator flips the bits, changing a 0 bit to a 1 bit. Generally,
you would use this only with TRUE and FALSE values to toggle between the two
(TRUE = NOT FALSE, FALSE = NOT TRUE), but it can be used with any number.
E.g.,

Not &h000000FF = &hFFFFFF00

If it is used with number other than -1 (TRUE) and 0 (FALSE), it would be
confusing and quite possibly wrong.

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting
www.cpearson.com
(email on the web site)

"peyman" wrote in message
...
hi,
can anybody explain to me what does "not" do in the following code:

With Sheets("Sheet1").OptionButton1 'code name for the button
.Value = Not .Value
End With
thanks



peyman

macro codes
 
thanx I got it.

"Dave Peterson" wrote:

The optionbutton's value can be true or false.

Not true = false
not false = true

The code toggles the optionbutton from checked to unchecked or vice versa.



peyman wrote:

hi,
can anybody explain to me what does "not" do in the following code:

With Sheets("Sheet1").OptionButton1 'code name for the button
.Value = Not .Value
End With
thanks


--

Dave Peterson


peyman

macro codes
 
thank you for your explanation.

"Chip Pearson" wrote:

The "Not" operator flips the bits, changing a 0 bit to a 1 bit. Generally,
you would use this only with TRUE and FALSE values to toggle between the two
(TRUE = NOT FALSE, FALSE = NOT TRUE), but it can be used with any number.
E.g.,

Not &h000000FF = &hFFFFFF00

If it is used with number other than -1 (TRUE) and 0 (FALSE), it would be
confusing and quite possibly wrong.

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting
www.cpearson.com
(email on the web site)

"peyman" wrote in message
...
hi,
can anybody explain to me what does "not" do in the following code:

With Sheets("Sheet1").OptionButton1 'code name for the button
.Value = Not .Value
End With
thanks




All times are GMT +1. The time now is 08:40 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com