The Power of Not

No matter how many years I’ve been coding I always learn something new.  A few days ago I need to take the opposite value of a boolean variable.  Normally I would use an Inline If statement (I’ve also heard it called Immediate If).  I don’t know why I do this, probably because of my beginnings in Access 2.0.

Button.Enabled = IIF(bValue, False, True)

After looking at the code and realizing something wasn’t right I thought about the problem.  How do I take the inverse of a boolean value?  Duh use Not!

So here is what I came up with:

Button.Enabled = Not bValue

Much better.  I wonder what I’m going to learn tomorrow?