Results 1 to 6 of 6

Thread: Figuring out if number is multiple of 14

  1. #1

    Thread Starter
    Frenzied Member msimmons's Avatar
    Join Date
    Jul 2001
    Location
    Houston, TX
    Posts
    1,057

    Figuring out if number is multiple of 14

    I need to know if a number is a multiple of 14. I am dynamicly creating a calendar where I don't know the dates I want to display are at design time. I want to show rows of 14 days. If the user's date range is 2 days then I need to make it 14 if their range is 15 I need to make it 28 (two rows of 14) if it is 30 I need 42, ect.
    I think I need to do something like :
    Code:
    intMod = intVar / 2 
    intMod = mod(intMod)
    if intMod = 0 then 
    do something
    but im not real sure, I havent worked with mod since pascal
    Michael

  2. #2
    Frenzied Member
    Join Date
    Feb 2001
    Posts
    1,140
    The modulus operator is what you want, but I can't help. I know of no good VB reference. That is my number one complaint with the language.

    You can try % to see if it works.
    Travis, Kung Foo Journeyman
    As always, RTFM.

    WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
    Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
    YBMS, but Mozilla doesn't.

  3. #3
    Frenzied Member
    Join Date
    Feb 2001
    Posts
    1,140
    Or, maybe something as bulky as:

    VB Code:
    1. intWhichSerie = intCurrIndex Mod 14
    Travis, Kung Foo Journeyman
    As always, RTFM.

    WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
    Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
    YBMS, but Mozilla doesn't.

  4. #4
    Addicted Member
    Join Date
    Nov 2001
    Location
    Peterborough, UK
    Posts
    160

    Or perhaps the most simple...

    way to find out if a number is a multiple of 14 is

    if mynumber / 14 = int (mynumber / 14) then

    end if




    Pigmy

  5. #5

    Thread Starter
    Frenzied Member msimmons's Avatar
    Join Date
    Jul 2001
    Location
    Houston, TX
    Posts
    1,057
    I think I'm going to do it with an if/then tree.

    Code:
    If datTotal <= 14 Then
    	datTotal = 14
    Else
    	If datTotal <= 28 Then
    		datTotal = 28
    	Else
    		If datTotal <= 42 Then
    			datTotal = 42
    		Else
    			'alert... you have too many days
    		End If
    	End If
    End If
    Michael

  6. #6
    Frenzied Member
    Join Date
    Feb 2001
    Posts
    1,140
    Code:
    <% @Language="VBScript" %>
    <html>
      <head></head>
      <body>
        <%If Request.Form("DayCount") <> "" Then%>
          <p>
            You should put 
            <%
              If (Request.Form("DayCount") Mod 14) Then 
                Response.Write(Int(Request.Form("DayCount") / 14 + 1) * 14)
              Else
                Response.Write(Int(Request.Form("DayCount") / 14) * 14)
              End If
            %> 
            days on the calendar.
          </p>
        <%End If%>
        <form action="daycount.asp" method="post">
          <input type="text" name="DayCount">
          <input type="submit">
        </form>
      </body>
    </html>
    Travis, Kung Foo Journeyman
    As always, RTFM.

    WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
    Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
    YBMS, but Mozilla doesn't.

Posting Permissions

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



Click Here to Expand Forum to Full Width