SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Wizard dethfire's Avatar
    Join Date
    Aug 2000
    Posts
    2,477
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am trying to make a GPA calculator, this page is the last step once the person has fillout out a form telling the third page the grades and how many classes he/she has.

    but... here is an error I have no clue how to fix:

    ------------------------------------------------
    Microsoft VBScript runtime error '800a0006'

    Overflow

    /link/third.asp, line 78
    ---------------------------------------------------

    here is my code for the third page, where I announce gpa's value is where the error accurs (line 78)

    --------------------------------------------------

    <%@ Language="VBscript" %>

    <%
    dim noclasses, hoursnew, arrgrade(8)
    dim arrhour(8), counter, counter2, total, grandtotal

    counter = 1
    counter2 = 1
    noclasses = request.form("classesnum")
    hoursnew = request.form("hoursnew")
    arrhour(hoursnew)= array(request.form("1"), request.form("2"), request.form("3"), request.form("4"), request.form("5"), request.form("6"), request.form("7"), request.form("8"))
    arrgrade(hoursnew)= array(1, 2, 3, 4, 5, 6, 7, 8)

    for score = 1 to hoursnew

    if arrhour(counter) = "A+" then
    arrgrade(counter2)= 4.33

    elseif arrhour(counter)= "A" then
    arrgrade(counter2)= 4.0

    elseif arrhour(counter)= "A-" then
    arrgrade(counter2)= 3.67

    elseif arrhour(counter)= "B+" then
    arrgrade(counter2)= 3.33

    elseif arrhour(counter)= "B" then
    arrgrade(counter2)= 3.00

    elseif arrhour(counter)= "B-" then
    arrgrade(counter2)= 2.67

    elseif arrhour(counter)= "C+" then
    arrgrade(counter2)= 2.33

    elseif arrhour(counter)= "C" then
    arrgrade(counter2)= 2.00

    elseif arrhour(counter)= "C-" then
    arrgrade(counter2)= 1.67

    elseif arrhour(counter)= "D+" then
    arrgrade(counter2)= 1.33

    elseif arrhour(counter)= "D" then
    arrgrade(counter2)= 1.00

    elseif arrhour(counter)= "D-" then
    arrgrade(counter2)= .67

    else
    arrgrade= 0

    end if

    counter = counter + 1
    counter2 = counter2 + 1

    next
    %>


    <% total= arrgrade(1) + arrgrade(2) + arrgrade(3) + arrgrade(4) + arrgrade(5) + arrgrade(6) + arrgrade(7) + arrgrade(8)

    gpa = total / classesnum

    %>

    Here is your GPAbr>
    <%=gpa%>
    Free Science Homework Help
    http://www.physicsforums.com

  2. #2
    Just Blow It bronze trophy
    DaveMaxwell's Avatar
    Join Date
    Nov 1999
    Location
    Mechanicsburg, PA
    Posts
    7,254
    Mentioned
    113 Post(s)
    Tagged
    1 Thread(s)
    I believe arrays have to start with 0, not with 1. Your loop should go from 0 to (hournew - 1) instead of 1 to hournew.

    And looking at your code quickly, I don't think this is going to provide you with what you want. You've got arrays within arrays, but you're only trying to access the outside array. I don't think you'll get what you want. Here's what I mean.

    You've got an array called arrhour. Say hoursnew = 4 and you're form("1") = A+, etc. The way you've got it declared (unless I understand arrays incorrectly), you'll have this in arrhour(- means null):

    arrhour(0) = - - - - - - - -
    arrhour(1) = - - - - - - - -
    arrhour(2) = - - - - - - - -
    arrhour(3) = - - - - - - - -
    arrhour(4) = A+ A A- B+ B B- C+ C

    I think the correct declaration for the array would be(this is based on an example from ASP101:
    arrhour array(request.form("1"), request.form("2"), request.form("3"), request.form("4"), request.form("5"), request.form("6"), request.form("7"), request.form("8"))

    Here is the link if you want to see what I used as a reference. Good luck!!!
    Dave Maxwell - Manage Your Site Team Leader
    My favorite YouTube Video! | Star Wars, Dr Suess Style


Bookmarks

Posting Permissions

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