Go Premium for a chance to win a PS4. Enter to Win

x
Solved

# Is even or odd?

Posted on 2000-03-03
Medium Priority
315 Views
Does someone have a function in which I can pass an
Integer and it would return True if Even or False if odd?

0
Question by:blue021097
• 3

LVL 32

Accepted Solution

jhance earned 200 total points
ID: 2581555
Function EvenOrOdd(num)

If ((num / 2) * 2) = num Then
EvenOrOdd = True
Else
EvenOrOdd = False
End If

End Function
0

Author Comment

ID: 2581645
(Edited by Computer101), it is not working.
0

LVL 32

Expert Comment

ID: 2581673
Well what's it doing?
0

LVL 32

Expert Comment

ID: 2581683
OK, I see the problem.  Try it like this:

Function EvenOrOdd(num)

If (Int((num / 2)) * 2) = num Then
EvenOrOdd = True
Else
EvenOrOdd = False
End If

End Function
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
###### Suggested Courses
Course of the Month12 days, 10 hours left to enroll