PDA

View Full Version : Boolean switch


adamskii
03-07-2008, 03:31 PM
Hi, simple question that Im sure must have a simple answer, but I cant find it!

This is what i have:
function boolSwitch(bool)
if bool then
boolSwitch=false
else boolSwitch=true end if
end function
Is there simpler way of switching a boolean value? (i.e. if true, set to false. if false, set to true).

I know in C++ you can do: boolValue = !boolValue
But it'd b nice to find a (clean) way to do it in VBScript

Spudhead
03-07-2008, 05:22 PM
function boolSwitch(bool)
boolSwitch = not bool
end function

That's the shortest way I can think of, I'd assume it was faster but I have no idea :)

adamskii
03-11-2008, 02:16 PM
thats just what i was looking for, thanks coming your way.

No function needed:
boolValue = not boolValue