even
How do I find out if a variable is even?
Thanks |
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 |
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 |
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 |
All times are GMT +1. The time now is 09:09 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com