Hello all,
I ask this question because I searched and did not find anything that related to this query. My apologies if this is a mistake.
Please see the following code. I am using 2 ASP pages. One to fill up a decimal value (it is actually the unit price of something) and the other to receive and process it. The value in the first page can be entered by the user as a whole number OR as a number with decimal places. Ex. 2345.88 since products tend to have that kind of values.
Now this is in the second ASP page where I receive it. -
<%
-
-
Dim price
-
-
' Let us assume I entered 1245.76 in the previous form
-
price = Request.form("price")
-
Response.write price
-
-
'The above print will show 1245.76 without problems. So far so good.
-
-
'But then I do some math with it and print it.
-
-
price = price * 5.5
-
Response.write price %>
-
And this time it prints 685168 where as it should print 6851.68 and hence the data is completely incorrect.
I tried FormatNumber which did not work. Someone suggested "&FormatNumber(price,2)&" which also did not work.
Help please!
Thank you so much.
Sk
11 3121
Sk,
That's odd. I just tried it here and it worked fine.
Jared
Sk,
That's odd. I just tried it here and it worked fine.
Jared
yes....it does work fine in your example. In mine it still does not work properly. Any functions or formatting structures you might know to help me with this?
Please help.
Sk
yes....it does work fine in your example. In mine it still does not work properly. Any functions or formatting structures you might know to help me with this?
Please help.
Sk
I can't think of anything off hand, maybe if I saw your code...
Are you using a formatPercent or something similar at some point?
Jared
I can't think of anything off hand, maybe if I saw your code...
Are you using a formatPercent or something similar at some point?
Jared
Nope. Nothing of that sort. Just a plain old Request.QueryString from a textbox of another ASP file. The value that enters the second page is stored as Dim and thats about it.
Could this be some server sided issue? Like some regional setting on the server that its running on? What do you think?
Sk
The example that you originally provided is completely sound, there's no reason for that simple example not to work, which makes me think there's got to be something in your code interfering with it and dropping the decimal places somewhere.
To be of any help to you I think we'll need to see your code.
You're not treating the number with any numerical functions are you? A lot of numerical functions like CInt() in asp will kill the decimal places and turn it into a whole number, or just drop the decimal numbers all together in order to derive a whole number.
My best guess is that you've probably got something like that in there, but If that's not the case - show your code so we can look through it and see what's going on.
Here is the code sample. Kindly help.
test.asp
----------- -
<html>
-
-
<head>
-
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
-
<meta name="ProgId" content="FrontPage.Editor.Document">
-
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
-
<title>New Page 1</title>
-
</head>
-
-
<body>
-
-
<form method="GET" action="displayDec.asp">
-
<p><input type="text" name="price" size="20"></p>
-
<p><input type="submit" value="Submit" name="B1"></p>
-
</form>
-
-
</body>
-
-
</html>
-
displayDec.asp
--------------------- - <%
-
-
Dim price
-
-
price = Request.QueryString("price")
-
Response.Write("Before multiplying it: " & price)
-
price = price * 7.2
-
Response.Write("<br>" & "After multiplying it with 7.2 : " & price)
-
%>
SAMPLE OUTPUTS (and a NEW error! :( )
--------------------------
If I enter 2.0 in price then it prints 144.
If I enter just the number 2 in price then it prints 14,4 (this did not happen before. I don't know why it is printing a COMMA now instead of a decimal place!!!!)
If I enter 0.01 then it prints 7,2 (again the comma appears)
PLEASE help guys. This thing is totally freaking me out. :(
Cheers,
Sk
Here is the code sample. Kindly help.
test.asp
----------- -
<html>
-
-
<head>
-
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
-
<meta name="ProgId" content="FrontPage.Editor.Document">
-
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
-
<title>New Page 1</title>
-
</head>
-
-
<body>
-
-
<form method="GET" action="displayDec.asp">
-
<p><input type="text" name="price" size="20"></p>
-
<p><input type="submit" value="Submit" name="B1"></p>
-
</form>
-
-
</body>
-
-
</html>
-
displayDec.asp
--------------------- - <%
-
-
Dim price
-
-
price = Request.QueryString("price")
-
Response.Write("Before multiplying it: " & price)
-
price = price * 7.2
-
Response.Write("<br>" & "After multiplying it with 7.2 : " & price)
-
%>
SAMPLE OUTPUTS (and a NEW error! :( )
--------------------------
If I enter 2.0 in price then it prints 144.
If I enter just the number 2 in price then it prints 14,4 (this did not happen before. I don't know why it is printing a COMMA now instead of a decimal place!!!!)
If I enter 0.01 then it prints 7,2 (again the comma appears)
PLEASE help guys. This thing is totally freaking me out. :(
Cheers,
Sk
Is there some reason you can't use method=post rather than method=get? I'm not sure if this is causing a problem, but it might. Things sent by querystring need to be formatted for putting in the querystring and I think a period is a special character in a URL.
Using a comma rather than a decimal point is a region-specific behavior. Check your server's region settings.
Jared
Is there some reason you can't use method=post rather than method=get? I'm not sure if this is causing a problem, but it might. Things sent by querystring need to be formatted for putting in the querystring and I think a period is a special character in a URL.
Using a comma rather than a decimal point is a region-specific behavior. Check your server's region settings.
Jared
Dear Jared,
That is what I thought as well. But I tried it with POST and Request.Form and the same thing happens. So I don't think it is the GET which is causing the problem.
So could you please help in showing how exactly values are formatted for such scenarios using QueryString?
And you are right. I am pretty sure it has something to do with the server settings here. I will have to look into that.
Thank you.
Sk
I agree with Jared, it's got to be something server specific. In fact, almost all regions use a comma instead of a period to donate a decimal place, So i would definately check that first. Though, after running your code I did change the region on my personal computer and my server to finish and re-ran the page and did not get a comma as a decimal place.
I ran your exact code, without modifying it, and the following was returned:
Before multiplying it: 7
After multiplying it with 7.2 : 50.4
Correct calculation and correct use of decimal places etc.
I agree with Jared, it's got to be something server specific. In fact, almost all regions use a comma instead of a period to donate a decimal place, So i would definately check that first. Though, after running your code I did change the region on my personal computer and my server to finish and re-ran the page and did not get a comma as a decimal place.
I ran your exact code, without modifying it, and the following was returned:
Before multiplying it: 7
After multiplying it with 7.2 : 50.4
Correct calculation and correct use of decimal places etc.
Hmm....I dont know what else to do now. I even showed the problem to my network admin here but she insists it is not a server related issue. I have given her the code....lets see what happens.
Thank you.
Sk
It has to be, I honesly don't see what else it could be! If Jared and I can copy and paste your exact code that you specified in previous post(s) and run it on our servers and it does return the desired result, but doesn't on the server which you're running it on - then there's only one difference there. That difference being the environment that it's being run in.
Well, hopefully he/she can come up with something to fix the problem!
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Techy |
last post by:
I have hancoded the asp page for inserting the values into an Ms Access
> Database and it work fine
>
> The problem I am facing is that once I insert any value with Decimals like
"
> 11.95" or...
|
by: Chad Z. Hower aka Kudzu |
last post by:
I have a typed dataset that is on a WinForm and I have labels that have their
text properties bound to fields in a data table. The values are of type
decimal. When I dispaly them in the label, I...
|
by: Tommi Mäkitalo |
last post by:
Hi
I need to format floating-point-numbers with exact 2 digits after decimal
point. I could use printf with "%.2f", but it don't use std::locale.
Any ideas?
--
Tommi Mäkitalo
|
by: Douglas |
last post by:
Gday,
How would I format a number so that:
TheValue = 32500
Displays in the TextBox as: $32,500.00
|
by: Dave Brydon |
last post by:
Access 2003
I have a combo box in my personnel table, which draws its data from a trade
code table; the original field in the code table, is numeric, Long Integer,
and formatted with 5 zero's . ...
|
by: BBFrost |
last post by:
I'm receiving decimal values from database queries and placing them on a
report page.
The users want to see the following ....
Db Value Display Value
123.3400 123.34...
|
by: Earl |
last post by:
Still trying to clean up some datagrid formatting issues from the past.
When I bring in money values from a stored procedure, I'm getting 4 decimal
places in the grid ( which of course I only...
|
by: Scott M. |
last post by:
Ok, this is driving me nuts...
I am using VS.NET 2003 and trying to take an item out of a row in a
loosely-typed dataset and place it in a label as a currency. As it is now,
I am getting my...
|
by: Pittaman |
last post by:
Hello
I am creating some crystal reports (for visual studio 2005) based on the content of certain .NET objects. I'm doing this in .NET 2.0.
For one of them I'm using a Cross-table to summarize...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |