VB Runtime Error - Overflow - Divisable by zero

Posted on 2006-03-31
Last Modified: 2008-03-04
Hi i have this code that fails at line Response.Write intWins/intGames as soon as i have a zero a value (divisable by 0)

                  Set RS_Entrant = Server.CreateObject("ADODB.Recordset")
                  SQL_Entrant = "SELECT * FROM tblEntrants"
                  RS_Entrant.Open SQL_Entrant,Connection,3,3
                  Do While Not RS_Entrant.EOF
                  intName = RS_Entrant("txtName")
                  intGames = RS_Entrant("intGames")
                  intWins = RS_Entrant("intWins")
                              <td><% Response.Write intName %></td>
                              <td><% Response.Write intGames %></td>
                              <td><% Response.Write intWins %></td>
                              IF isNull(intWins) OR isNull(intGames) THEN
                                    Response.Write "No Data"
                                    Response.Write intWins/intGames
                              END IF
                  Set RS_Entrant = Nothing

Can any one help?
Question by:net-workx
    LVL 19

    Accepted Solution

    You should probably look at your logic to find out why you would be dividing by a value that might be zero, but the following should eliminate the error.

      IF isNull(intWins) OR isNull(intGames) THEN
         Response.Write "No Data"
        if intGames <> 0 then
          Response.Write intWins/intGames
          Response.write 0
        end if
      END IF

    Author Comment

    Its for a little tournament thing so logic is ok, just that if someone hasnt won anything then it cant divide!

    Anyway, you got the points!

    Thanks for help!

    LVL 19

    Expert Comment

    Glad I could help,


    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
    I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…

    730 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now