Results 1 to 4 of 4

Thread: Modulus

  1. #1
    Conrad Guest

    Default Modulus

    How is the modulus function used in ASP?<BR><BR>Thanks.<BR><BR>Conrad

  2. #2
    Pedantic Bill Guest

    Default RE: Modulus

    Do you mean "How do you code it?" or "What is it used for?"<BR><BR>And you said "ASP". Do you mean "VBScript" or "JScript" or some other scripting language?<BR><BR>ASP, per se, has nothing to do with programming. It is only when the technology is combined with a scripting language that a question regarding modulus becomes meaningful.<BR><BR>Taking the easy way out, I&#039ll assume that you mean "What syntax in VBScript is used to implemented a modulus function?"<BR><BR>And the answer to that: MOD<BR><BR>As in<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;Counter = ( Counter + 1 ) MOD 10<BR><BR>which will give you a counter that goes from 0 to 9 and then back to 0 to 9 and then back to 0 to 9 and ...<BR><BR>

  3. #3
    Conrad Guest

    Default Clarification

    What I want to do is see if a number is even or odd.<BR>Yes, I was referring to VBScript.<BR><BR>Thanks.<BR><BR>Conrad

  4. #4
    Join Date
    Dec 1969

    Default RE: Clarification

    Ahhh! Then see my other post re isEven and isOdd.<BR><BR>Using the AND operator is easier than MOD.<BR><BR>I did think of an improvement to my earlier posting:<BR><BR>Function isEven( num )<BR>&nbsp;&nbsp;&nbsp;&nbsp;isEven = ( (CInt(num) AND 1) = 0 )<BR>End Function<BR><BR>If you aren&#039t 100% sure that the argument to the function will be an integer, then the CInt call there will provide you the insurance you need.<BR><BR> know, with modern computers, and with the builtin inefficiency of VBScript, we are *maybe* talking one tenthousandth of a percent more efficiency. Maybe. So if you want to do<BR><BR>Function isEven( num )<BR>&nbsp;&nbsp;&nbsp;&nbsp;isEven = ( (CInt(num) MOD 2) = 0 )<BR>End Function<BR><BR>go for it.<BR><BR>

Posting Permissions

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