• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 193
  • Last Modified:

VB Runtime Error - Overflow - Divisable by zero

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")
                  %>
                        <tr>
                              <td><% Response.Write intName %></td>
                              <td><% Response.Write intGames %></td>
                              <td><% Response.Write intWins %></td>
                              <td>
                              <%
                              IF isNull(intWins) OR isNull(intGames) THEN
                                    Response.Write "No Data"
                              ELSE
                                    Response.Write intWins/intGames
                              END IF
                              %>
                              </td>
                              <td>&nbsp;</td>
                              <td>&nbsp;</td>
                        </tr>
                  <%
                  RS_Entrant.MoveNext
                  Loop
                  RS_Entrant.Close
                  Set RS_Entrant = Nothing
                  %>

Can any one help?
0
net-workx
Asked:
net-workx
  • 2
1 Solution
 
nschaferCommented:
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"
  ELSE
    if intGames <> 0 then
      Response.Write intWins/intGames
    else
      Response.write 0
    end if
  END IF
0
 
net-workxAuthor Commented:
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!

Carl
0
 
nschaferCommented:
Glad I could help,

Neal.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now