Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 11 of 11

Thread: overflow?

  1. #1
    Senior Coder Mhtml's Avatar
    Join Date
    Jun 2002
    Location
    Sydney, Australia
    Posts
    3,531
    Thanks
    0
    Thanked 1 Time in 1 Post

    overflow?

    I'm making a small calculator project which will write the amount of fence posts needed for a fence on my parents farm depending on the input from the form. .

    Here is what I'm using.
    Code:
    <%
    dim PostNo  'The variable for the number of posts
    dim PostSp  'The variable for spacing between posts
    dim PaceAm 'The variable for the amount of paces
    dim PaceSz  'The variable for the size of the paces
    
    PostSp  = Request.Form("fPostSp")
    PaceAm = Request.Form("fPaceAm")
    PaceSz  = Request.Form("fPaceSz")
    
    PostNo = PaceAm*PaceSz/PostSp
    
    Response.Write(PostNo)
    %>
    I get an error stating overflow. What does it mean? Is it that the variable has to much information?
    Omnis mico antequam dominus Spookster!

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    10,950
    Thanks
    0
    Thanked 236 Times in 233 Posts
    what's the expected value of PostNo?

  • #3
    Senior Coder Mhtml's Avatar
    Join Date
    Jun 2002
    Location
    Sydney, Australia
    Posts
    3,531
    Thanks
    0
    Thanked 1 Time in 1 Post
    Not quite clear on what you mean.
    Omnis mico antequam dominus Spookster!

  • #4
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    10,950
    Thanks
    0
    Thanked 236 Times in 233 Posts
    when you ran the code, what is supposed to be the value of PostNo variable, is it too big?

  • #5
    Senior Coder Mhtml's Avatar
    Join Date
    Jun 2002
    Location
    Sydney, Australia
    Posts
    3,531
    Thanks
    0
    Thanked 1 Time in 1 Post
    PostNo is supposed to hold the result of the calculation.
    Omnis mico antequam dominus Spookster!

  • #6
    Senior Coder Mhtml's Avatar
    Join Date
    Jun 2002
    Location
    Sydney, Australia
    Posts
    3,531
    Thanks
    0
    Thanked 1 Time in 1 Post
    I've tried multiple ways but I can seem to devide the number which I have stored in a variable.

    Simply I times two numbers together and then divide the answer but I get an overflow error when I try to divide.
    Omnis mico antequam dominus Spookster!

  • #7
    Regular Coder
    Join Date
    Jun 2002
    Location
    Cincinnati, OH
    Posts
    545
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Is it just an "overflow" error, try putting an --> On Error Resume Next at the beginning of your code.

  • #8
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    This is the page I made up and it appears to work. I added some validation in because without it, if one of the variables is empty it errors out.

    Code:
    <HEAD>
    <TITLE>Fence post calculator</TITLE>
    </HEAD>
    
    <BODY>
    
    <p>
    <FORM action="" Method="Post">
    Spacing between posts:<INPUT type="text" name="fPostSp"><BR>
    Ammount of paces:<INPUT type="text" name="fPaceAm"><BR>
    Size of paces:<INPUT type="text" name="fPaceSz"><BR><BR>
    
    <INPUT type="Submit" value="Calculate">
    </FORM>
    </p>
    
    <%
    dim PostNo  'The variable for the number of posts
    dim PostSp  'The variable for spacing between posts
    dim PaceAm 'The variable for the amount of paces
    dim PaceSz  'The variable for the size of the paces
    
    PostSp  = Request.Form("fPostSp")
    PaceAm = Request.Form("fPaceAm")
    PaceSz  = Request.Form("fPaceSz")
    
    If PostSP > 0 And PaceAm > 0 And PaceSz > 0 Then
    
    PostNo = PaceAm*PaceSz
    PostNo=PostNo/PostSp
    %>
    
    <p><%=PostNo%> required posts.</p>
    <%End If%>
    
    </BODY>
    Last edited by oracleguy; 08-03-2002 at 12:44 AM.
    OracleGuy

  • #9
    Regular Coder Feyd's Avatar
    Join Date
    May 2002
    Location
    Los Angeles, CA Maxim: Subvert Society
    Posts
    404
    Thanks
    0
    Thanked 0 Times in 0 Posts
    But actually doing <p><%=PostNo%> required posts.</p> is much more entertaining than the long way

    Are you trying to cast a number larger than 32,000 to an integer?

    I've had similar problems when dealing with regional settings for decimal seperators and the thousands, but that doesn't seem to be the case for you...

    Usually you get this error when you are over the limit on Request.Form. ASP's limit for form processing is supposed to be about 100k, according to Micro$oft, it breaks down further to a max of 102,399 bytes for each field. Which, again, doesn't seem like it should be affecting you, depending on what you are sending into the form...if it is the case, however, you can always use the old dirty trick of using your own function to deal with the form handling and therefore get around the overflow fatality.
    Moderator, Perl/CGI Forum
    shadowstorm.net - subvert society

  • #10
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    Originally posted by Feyd
    But actually doing <p><%=PostNo%> required posts.</p> is much more entertaining than the long way
    I usually do that... i did it that way cuz i was "adapting" his existing code. I'll change it.

  • #11
    Senior Coder
    Join Date
    Jun 2002
    Location
    41 8' 52" N -95 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Probably if you used some parentheses the first way would work, too.
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)


  •  

    Posting Permissions

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