how do you find odd and evan numbers of a integer

Posted on 2004-11-18
Last Modified: 2008-03-17
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 forms

thanks in advance
aka Pern
Question by:Johnny
    LVL 14

    Assisted Solution

    I do not know 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
    SearchNumFind = Yes
    end if

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

    searchNum mod 2 = 0 or

    hope this will help....

    LVL 44

    Accepted Solution

    try this:

    Dim iVal as Integer

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

    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.


    Author Comment

    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
    LVL 44

    Expert Comment

    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


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



    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Join & Write a Comment

    Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
    The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now