Forum Moderators: open

Message Too Old, No Replies

Determining if a number is equal/unequal

function?

         

Darkelve

11:24 am on Mar 2, 2007 (gmt 0)

10+ Year Member



Is there a function that can tell if a number is equal or unequal, and if yes, how can I use it (what is the syntax)?

aspdaddy

7:27 pm on Mar 2, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Im assuming you mean even or odd?

if (x mod 2=0)
x is even
else
x is odd

Easy_Coder

7:50 pm on Mar 2, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



on the flip side of that there's....

function NumbersAreEqual(y, z)

if isnumeric(y) and isnumeric(z) then
if y = z then
retval = true
else
retval = false
end if
else
retval = false
end if

NumbersAreEqual = retval

end function

[edited by: Easy_Coder at 7:51 pm (utc) on Mar. 2, 2007]

aspdaddy

6:08 pm on Mar 3, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You dont need to write a function , the = operator determines if value on the left is equal to the value of the right.

TheNige

3:55 am on Mar 6, 2007 (gmt 0)

10+ Year Member



I was going to mention that too...Easy_Coder's solution would work well though if you are using late binding and generic objects to hold your data...as there could potentially be alphas coming into his function.

If you are using option strict and strongly defined types then yeah...use the = operator.