Check whether a Number is Odd or Even

The VBScript Mod operator divides two numbers and returns the remainder. So in our code the parameter 'iNumber' passed into our subroutine OddEvenNumber is divided by 2. If the remainder is 0 then the number is even.

Sub OddEvenNumber(iNumber)
If iNumber MOD 2 = 0 Then
Response.write "The number " & iNumber & " is EVEN<br />"
Response.write "The number " & iNumber & " is ODD<br />"
End If
End Sub

'Call our sub and pass in the number 4 as a parameter
Call OddEvenNumber(4)
'Call our sub and pass in the number 13 as a parameter
Call OddEvenNumber(13)

The result of our code above is:
The number 4 is EVEN
The number 13 is ODD

Get the best ASP hosting with DiscountASP.NET - great value, money back guarantee.



MembersPro PayPal - ASP Membership software

Plug and play ASP membership script that integrates with PayPal to let you charge recurring membership fees.

Global ASP.NET Hosting Leader - Click Here