p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Classic ASP Basics (http://p2p.wrox.com/forumdisplay.php?f=61)
-   -   Divided by Zero and Print Landscape (http://p2p.wrox.com/showthread.php?t=29287)

mateenmohd May 13th, 2005 08:25 AM

Divided by Zero and Print Landscape
 
I use following coding to calculate the percentage.


IF NOT RS.EOF THEN
do while rs.eof=false

totalBH1 = (totalBH1 + cint(rs("BH")))
Response.Write("<td align=center>" & rs("BH") & "</td>")

total1 = (total1 + cint(rs("total")))
Response.Write("<td align=center>" & rs("total") & "</td>")

rs.movenext
loop

per = (total1/totalBH1)*100 // line 187

end if

"<td align=center>" & per & "%" &"</td>" & _


some time values in totalBH1 is zero it give following error

Error Type:
Microsoft VBScript runtime (0x800A000B)
Division by zero
/tabulation/bmhours/FOWMHR2.asp, line 187


Zero can not be divided to any values. it is infinate value.
how can control this ?
if totalBH1 is ZERO it should display 0% how ?

in the PER field.

2. Secondly problem.

   How can print the ASP page invoice in LANDSCAPE and
   PORTRAIT ? and should be pring in center alignment.

3. how can set the printer setting in asp page ?

regards.

Mateen








mat41 May 13th, 2005 05:53 PM

;;;Zero can not be divided to any values. it is infinate value.
how can control this
if totalBH1 > 0 then
   per = (total1/totalBH1)*100
else
   per = 0
end if

;;;How can print the ASP page invoice in LANDSCAPE and PORTRAIT ? and should be pring in center alignment.
Use percentages on your tables

;;;how can set the printer setting in asp page ?
If percentages are used properly, this is not an issue.


Wind is your friend
Matt

happygv May 13th, 2005 06:53 PM

Yes, Mat is right. Try that, you should be through.

_________________________
- Vijay G
Strive for Perfection

mateenmohd May 14th, 2005 05:01 AM

Thanks a lot.

I have also more then one pages invoice.
if I have two page invoice
How I can print first page heading to next page ?
ie.

<table width="85%"...>
  <tr bgcolor="">

<th width="120" height="9" bgcolor="#f8f8ff"><span style="font-weight: 400">
    <em style="font-style: normal"><strong>
      Name</strong></em></span></th>
<th width="80" height="9" bgcolor="#f8f8ff"><span style="font-weight: 400">
    <em style="font-style: normal"><strong>
      Budgeted MH</strong></em></span></th>
 <th width="80" height="9" bgcolor="#f8f8ff"><span style="font-weight: 400">
    <em style="font-style: normal"><strong>
....
</tr>
....
asp coding....

...
loop close

</table>

Also print Name and Budgeted MH heading to next page ?

what change in the above loop coding ?

regards.

Mateen


All times are GMT -4. The time now is 06:00 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.