|
|
8000XXXX Errors ASP.NET 2.0 Classic ASP 1.0 Databases General Concepts Search Engine Optimization (SEO)Search | ASP FAQ Tutorials :: General Concepts :: How do I determine if a number is odd or even? How do I determine if a number is odd or even?Sometimes you need to know this because it's important; other times, it's simply for flipping the colors of adjacent rows in an HTML table. In any case, here are some samples of using the MODULUS operator on signed integers in T-SQL, VBScript and JScript: Transact-SQL This mimics retrieving a resultset from a table, along with a description of whether each id is odd or even. Note that ABS() is used so that the sign is ignored.
VBScript This uses a hardcoded value, so you can switch it around and test it before incorporating it into more significant code.
JScript This sample is just like the VBScript code above. The additional use of the Math object was required to convert the integer to positive.
|