# how do you find odd and evan numbers of a integer

how do you find 1,3,5,7,9 from 1,2,3,4,5,6,7,8,9

or if a number is odd or not

searchNum = 1
SearchNumFind = Yes

searchNum = 2
SearchNumFind = NO

how do you do that in vb.net forms

Johnny
aka Pern
###### Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Database DeveloperCommented:
I do not know vb.net but I try to figure it out, you should calculate the remainder of serchNum and if remainder is 0 then it is even else it is odd
like this

if mod(searchNum,2) = 0 then
SearchNumFind = No
else
SearchNumFind = Yes
end if

I use mod to calculate the remainder here
but it may be changed in vb.net it may be one of the following

searchNum mod 2 = 0 or
getRemainder(searchNum,2)

hope this will help....

Leo
0
Commented:
try this:

Dim iVal as Integer

for iVal = 1 to 9
If iVal Mod 2 = 0 then
MessageBox.Show("The Number " & ival & " Is Even")
else
MessageBox.Show("The Number " iVal & " Is Odd")
end if
Next

the Mod operator returns the REMAINDER when the value on the Left is divided by the value on the Right, and when the value on the Right is 2, it acts as an Odd/Even Filter.

AW
0

Experts Exchange Solution brought to you by

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Author Commented:
thx
i went with

If (intArray Mod 2) = 0 Then TextBox1.Text &= "<tr BGCOLOR='aliceblue'>" & vbCrLf 'even
If (intArray Mod 2) = 1 Then TextBox1.Text &= "<tr BGCOLOR='ghostwhite'>" & vbCrLf 'odd

and it works great

thx again
0
Commented:
this can be simplified:

If (intArray Mod 2) = 0 Then TextBox1.Text &= "<tr BGCOLOR='aliceblue'>" & vbCrLf 'even
If (intArray Mod 2) = 1 Then TextBox1.Text &= "<tr BGCOLOR='ghostwhite'>" & vbCrLf 'odd

to:

If intArray Mod 2 = 0 Then
TextBox1.Text &= "<tr BGCOLOR='aliceblue'>" & vbCrLf 'even
Else
TextBox1.Text &= "<tr BGCOLOR='ghostwhite'>" & vbCrLf 'odd
End If

AW

0
###### It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.