Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old July 19th, 2005, 02:17 PM
JStrauss
Guest
 
Posts: n/a
Default Calculation not working

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>


  #2  
Old July 19th, 2005, 02:17 PM
Bob Barrows [MVP]
Guest
 
Posts: n/a
Default Re: Calculation not working

JStrauss wrote:[color=blue]
> 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???
>[/color]
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
[color=blue]
> Thanks,
> Joe
>
> <%
> Dim strSDate1, strEng1, intHours1, intRate1, intSub1
>
> intHours1 = Trim(Request.Form("shours1"))
> intRate1 = Trim(Request.Form("srate1"))[/color]

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"


  #3  
Old July 19th, 2005, 02:17 PM
Ray at
Guest
 
Posts: n/a
Default Re: Calculation not working

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...[color=blue]
> Hello,
> I am having a problem getting some code to calculate/work in an ASP page.[/color]
In[color=blue]
> 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>
>
>[/color]


  #4  
Old July 19th, 2005, 02:18 PM
JStrauss
Guest
 
Posts: n/a
Default Re: Calculation not working

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...[color=blue]
> 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...[color=green]
> > Hello,
> > I am having a problem getting some code to calculate/work in an ASP[/color][/color]
page.[color=blue]
> In[color=green]
> > 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[/color][/color]
set[color=blue][color=green]
> > 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[/color][/color]
page.[color=blue][color=green]
> > 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>
> >
> >[/color]
>
>[/color]


  #5  
Old July 19th, 2005, 02:18 PM
Larry Bud
Guest
 
Posts: n/a
Default Re: Calculation not working

"JStrauss" <subs@strausselec.com> wrote in message news:<eZiKb$fbEHA.716@TK2MSFTNGP11.phx.gbl>...[color=blue]
> 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>[/color]

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.
  #6  
Old July 19th, 2005, 02:18 PM
Alex Kail
Guest
 
Posts: n/a
Default Re: Calculation not working

> 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"))
 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles