![]() |
Single command to toggle a Boolean?
In Excel 2000 VBA, is there one single command to toggle a Boolean - that
is, in whatever state it's in, change it to the opposite? I know it can be done with an If / Else - I was just wondering if there was a singe-line way to do it. Ed |
Single command to toggle a Boolean?
Ed wrote:
In Excel 2000 VBA, is there one single command to toggle a Boolean - that is, in whatever state it's in, change it to the opposite? I know it can be done with an If / Else - I was just wondering if there was a singe-line way to do it. Ed ---------------- Dim Flag as Boolean Flag = not(Flag) Bill |
Single command to toggle a Boolean?
Ed,
Use the Not operator. This will switch a boolean to its opposite. E.g, Dim Var As Boolean Dim Var As Boolean Var = Not Var -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Ed" wrote in message ... In Excel 2000 VBA, is there one single command to toggle a Boolean - that is, in whatever state it's in, change it to the opposite? I know it can be done with an If / Else - I was just wondering if there was a singe-line way to do it. Ed |
Single command to toggle a Boolean?
I have no idea how I got two Dim statements in the code. The
code should have only one Dim Statement. Dim Var As Boolean Var = Not Var -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Chip Pearson" wrote in message ... Ed, Use the Not operator. This will switch a boolean to its opposite. E.g, Dim Var As Boolean Dim Var As Boolean Var = Not Var -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Ed" wrote in message ... In Excel 2000 VBA, is there one single command to toggle a Boolean - that is, in whatever state it's in, change it to the opposite? I know it can be done with an If / Else - I was just wondering if there was a singe-line way to do it. Ed |
Single command to toggle a Boolean?
Thanks, Chip.
"Chip Pearson" wrote in message ... I have no idea how I got two Dim statements in the code. The code should have only one Dim Statement. Dim Var As Boolean Var = Not Var -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Chip Pearson" wrote in message ... Ed, Use the Not operator. This will switch a boolean to its opposite. E.g, Dim Var As Boolean Dim Var As Boolean Var = Not Var -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Ed" wrote in message ... In Excel 2000 VBA, is there one single command to toggle a Boolean - that is, in whatever state it's in, change it to the opposite? I know it can be done with an If / Else - I was just wondering if there was a singe-line way to do it. Ed |
Single command to toggle a Boolean?
Thanks, Bill.
"Bill Martin" wrote in message ... Ed wrote: In Excel 2000 VBA, is there one single command to toggle a Boolean - that is, in whatever state it's in, change it to the opposite? I know it can be done with an If / Else - I was just wondering if there was a singe-line way to do it. Ed ---------------- Dim Flag as Boolean Flag = not(Flag) Bill |
All times are GMT +1. The time now is 12:38 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com