Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > VBA / Office Integration > Excel > Excel VBA Opposite Boolean


Reply
 
Thread Tools Display Modes
  #1  
Old 02-03-2010, 07:28 PM
Josh Hazel Josh Hazel is offline
Senior Contributor
 
Join Date: May 2008
Posts: 805
Default Excel VBA Opposite Boolean


Just trying to learn new tricks...

If i want to get the opposite of a number value I just stick a "-" negative symbol in front of the variable ... can i do something like that for a boolean?

I just thought it would be cool to be like blnValue = -(blnValue) rather than an if/then statement to check its value and set its new value... I could create a function, but maybe there is something already built in?
__________________
Josh

If Google = NoHelp Then PostHere = True
Reply With Quote
  #2  
Old 02-03-2010, 08:58 PM
Kluz's Avatar
Kluz Kluz is offline
Sapience.Aquire

Super Moderator
* Expert *
 
Join Date: Oct 2003
Location: Lake Bluff, Ill., U.S.
Posts: 3,331
Default

The NOT keyword will reverse the value of a boolean:
Code:
Dim x As Boolean x = True x = Not x Msgbox x
__________________
No the other right mouse click
Reply With Quote
  #3  
Old 02-03-2010, 10:10 PM
Josh Hazel Josh Hazel is offline
Senior Contributor
 
Join Date: May 2008
Posts: 805
Default

Wow, your right ... i thought there must be an ez way for that =p
__________________
Josh

If Google = NoHelp Then PostHere = True
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->