Results 1 to 4 of 4

Thread: Checking if a number is even???

  1. #1

    Thread Starter
    Member
    Join Date
    May 2000
    Posts
    43
    Basically i have got a problem where i need to see if an integer is odd or even, can someone please help me on this task???
    Thanx
    Cease
    Cease

    This post has been brought to you with the help of:

  2. #2
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    Code:
    Option Explicit
    
    Private Sub Command1_Click()
        Dim i As Integer
        For i = 1 To 5
        If i Mod 2 <> 0 Then
          MsgBox i
        End If
        
        Next
    
    End Sub
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  3. #3
    Guest
    Take a look at this thread.

  4. #4
    Guest
    Try this code:

    Code:
    Public Function IsEven(I As Integer) As Boolean
        IsEven = Not I And 1
    End Function
    Usage:
    Code:
    Dim X as integer
    
    X=2       ' or any other number
    
    If IsEven(X) then
      msgBox X & " is even"
    else
      msgBox X & " is uneven"
    end if
    Have fun!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width