Results 1 to 3 of 3
  1. #1
    Star Lounger
    Join Date
    Apr 2004
    Posts
    66
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Odds & Evens (VB6)

    Can someone please give me the syntax for deciding whether a number is even or odd?
    This is for a function in Excel. I want to write an If Statement of the form: If number is even do this, otherwise do something else. Appreciate this should be dead simple, but I'm going round and round in circles.

    Many thanks

  2. #2
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: Odds & Evens (VB6)

    Hi,
    You can use:
    <code>If x Mod 2 = 0 then
    'Even
    Else
    'Odd
    End If
    </code>

    HTH
    Regards,
    Rory

    Microsoft MVP - Excel

  3. #3
    Star Lounger
    Join Date
    Apr 2004
    Posts
    66
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Odds & Evens (VB6)

    Hi

    Many thanks. Function works fine now.

    D

Posting Permissions

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