Hello,
I am having a problem getting some code to calculate/work in an ASP page. In
the snippet below I am collecting some data (inthours1 and intrate1) and
then want to calculate a value (intsub1) to display on the page. If I set
intsub1 to a fixed value, the page displays correctly. If I try the
calculation listed below, I get a 500 internal server error on the page.
What am I doing wrong???

Thanks,
Joe

<%
Dim strSDate1, strEng1, intHours1, intRate1, intSub1

intHours1 = Trim(Request.Form("shours1"))
intRate1 = Trim(Request.Form("srate1"))

' Sub total buckets
intSub1 = inthours1 * intrate1
%>
<td><INPUT TYPE=TEXT NAME="SHours1" VALUE="" SIZE=10 MAXLENGTH=10></td>
<td><INPUT TYPE=TEXT NAME="SRate1" VALUE="" SIZE=12 MAXLENGTH=12></td>
<td><%= intSub1 %> </td>

Re: Calculation not working by Bob

Bob
Mon Jul 19 21:29:04 CDT 2004

JStrauss wrote:
> Hello,
> I am having a problem getting some code to calculate/work in an ASP
> page. In the snippet below I am collecting some data (inthours1 and
> intrate1) and then want to calculate a value (intsub1) to display on
> the page. If I set intsub1 to a fixed value, the page displays
> correctly. If I try the calculation listed below, I get a 500
> internal server error on the page. What am I doing wrong???
>
Hard to say without knowing what the real error is. Follow the steps shown
in this article to enable the real error to be displayed:
http://www.aspfaq.com/show.asp?id=2109

> Thanks,
> Joe
>
> <%
> Dim strSDate1, strEng1, intHours1, intRate1, intSub1
>
> intHours1 = Trim(Request.Form("shours1"))
> intRate1 = Trim(Request.Form("srate1"))

We (you) can't troubleshoot this calculation without knowing what values are
going into it. Use Response.Write to facilitate debugging:

Response.Write "intHours1 contains """ & intHours1 & """<BR>"
Response.Write "intRate1 contains """ & intRate1 & """<BR>"
Response.End

If this doesn't tell you what the problem is, show us the result.

Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"



Re: Calculation not working by Ray

Ray
Mon Jul 19 21:29:56 CDT 2004

You need to know what an error is before you can debug it.

http://www.aspfaq.com/show.asp?id=2109

Ray at home

"JStrauss" <subs@strausselec.com> wrote in message
news:eZiKb$fbEHA.716@TK2MSFTNGP11.phx.gbl...
> Hello,
> I am having a problem getting some code to calculate/work in an ASP page.
In
> the snippet below I am collecting some data (inthours1 and intrate1) and
> then want to calculate a value (intsub1) to display on the page. If I set
> intsub1 to a fixed value, the page displays correctly. If I try the
> calculation listed below, I get a 500 internal server error on the page.
> What am I doing wrong???
>
> Thanks,
> Joe
>
> <%
> Dim strSDate1, strEng1, intHours1, intRate1, intSub1
>
> intHours1 = Trim(Request.Form("shours1"))
> intRate1 = Trim(Request.Form("srate1"))
>
> ' Sub total buckets
> intSub1 = inthours1 * intrate1
> %>
> <td><INPUT TYPE=TEXT NAME="SHours1" VALUE="" SIZE=10 MAXLENGTH=10></td>
> <td><INPUT TYPE=TEXT NAME="SRate1" VALUE="" SIZE=12 MAXLENGTH=12></td>
> <td><%= intSub1 %> </td>
>
>



Re: Calculation not working by JStrauss

JStrauss
Tue Jul 20 06:31:25 CDT 2004

Thanks for the tips. I am getting a type mismatch error, which I should be
able to track down. Thanks for the help.

Joe

"Ray at <%=sLocation%> [MVP]" <myfirstname at lane34 dot com> wrote in
message news:O6e$wEgbEHA.4092@TK2MSFTNGP10.phx.gbl...
> You need to know what an error is before you can debug it.
>
> http://www.aspfaq.com/show.asp?id=2109
>
> Ray at home
>
> "JStrauss" <subs@strausselec.com> wrote in message
> news:eZiKb$fbEHA.716@TK2MSFTNGP11.phx.gbl...
> > Hello,
> > I am having a problem getting some code to calculate/work in an ASP
page.
> In
> > the snippet below I am collecting some data (inthours1 and intrate1) and
> > then want to calculate a value (intsub1) to display on the page. If I
set
> > intsub1 to a fixed value, the page displays correctly. If I try the
> > calculation listed below, I get a 500 internal server error on the
page.
> > What am I doing wrong???
> >
> > Thanks,
> > Joe
> >
> > <%
> > Dim strSDate1, strEng1, intHours1, intRate1, intSub1
> >
> > intHours1 = Trim(Request.Form("shours1"))
> > intRate1 = Trim(Request.Form("srate1"))
> >
> > ' Sub total buckets
> > intSub1 = inthours1 * intrate1
> > %>
> > <td><INPUT TYPE=TEXT NAME="SHours1" VALUE="" SIZE=10 MAXLENGTH=10></td>
> > <td><INPUT TYPE=TEXT NAME="SRate1" VALUE="" SIZE=12 MAXLENGTH=12></td>
> > <td><%= intSub1 %> </td>
> >
> >
>
>



Re: Calculation not working by larrybud2002

larrybud2002
Tue Jul 20 07:54:56 CDT 2004

"JStrauss" <subs@strausselec.com> wrote in message news:<eZiKb$fbEHA.716@TK2MSFTNGP11.phx.gbl>...
> Hello,
> I am having a problem getting some code to calculate/work in an ASP page. In
> the snippet below I am collecting some data (inthours1 and intrate1) and
> then want to calculate a value (intsub1) to display on the page. If I set
> intsub1 to a fixed value, the page displays correctly. If I try the
> calculation listed below, I get a 500 internal server error on the page.
> What am I doing wrong???
>
> Thanks,
> Joe
>
> <%
> Dim strSDate1, strEng1, intHours1, intRate1, intSub1
>
> intHours1 = Trim(Request.Form("shours1"))
> intRate1 = Trim(Request.Form("srate1"))
>
> ' Sub total buckets
> intSub1 = inthours1 * intrate1
> %>
> <td><INPUT TYPE=TEXT NAME="SHours1" VALUE="" SIZE=10 MAXLENGTH=10></td>
> <td><INPUT TYPE=TEXT NAME="SRate1" VALUE="" SIZE=12 MAXLENGTH=12></td>
> <td><%= intSub1 %> </td>

You have to convert the request.form to an int or float before you can
multiply it, don't you?

i.e.

intHours1=cint(trim(request.form("shours1"))

You should do some type checking before this.

Re: Calculation not working by kail3

kail3
Tue Jul 20 14:49:23 CDT 2004

> intHours1=cint(trim(request.form("shours1"))

Take this a step further and append a zero to the beginning. CInt will
throw an error if there is nothing in request.form("shours1"). So do
this:

intHours1 = cint("0" & trim(request.form("shours1"))