Question:

Visual Basic Programming Help?

by  |  earlier

0 LIKES UnLike

Hi, im a little new to programming and i need help in here

hehe a bit stuck :P

ok, the problem is how do i program or what is the syntax for determining ODD from EVEN

what i'm trying to make is when you input a number is it will display if its ODD or EVEN

 Tags:

   Report

4 ANSWERS


  1. Dim myNum as Long

    myNum = Val(Text1)

    If myNum Mod 2 Then

    MsgBox "You've entered an odd number."

    Else

    MsgBox "You've entered an even number."

    End If


  2. divide the number by 2. If you have a remainder then it's odd.




  3. "Public Function IsEven(ByVal Number As Long) As Boolean

        IsEven = (Number Mod 2 = 0)

    End Function"

  4. Use the MOD function.

    If myVariable MOD 2 = 0 Then

    ' This is where the variable's value is even

    Else

    ' This is where the variable's value is odd

    End If

Question Stats

Latest activity: earlier.
This question has 4 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.