Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
even
How do I find out if a variable is even?
Thanks |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
even
Use the MOD function
myvariable = 9 If (myvariable Mod 2) 0 Then MsgBox "Odd" Else MsgBox "Even" End If Mike "ranswert" wrote: How do I find out if a variable is even? Thanks |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
even
Thanks I'll give that a try.
"Mike H" wrote: Use the MOD function myvariable = 9 If (myvariable Mod 2) 0 Then MsgBox "Odd" Else MsgBox "Even" End If Mike "ranswert" wrote: How do I find out if a variable is even? Thanks |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
even
You can also do it this way (execution should be marginally faster)...
MyVariable = 9 If MyVariable And 1 Then MsgBox "Odd" Else MsgBox "Even" End If Rick "Mike H" wrote in message ... Use the MOD function myvariable = 9 If (myvariable Mod 2) 0 Then MsgBox "Odd" Else MsgBox "Even" End If Mike "ranswert" wrote: How do I find out if a variable is even? Thanks |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|