How to knock off decimal places..

D

Davey

I have some code that divides a number and then prints this number. It
performs a cost rollup basically and then adds a percentage. The code works
fine except that the number returned has many figures afert the decimal
point (as you would expect really)
How can I remove these ? I am not really concerned about rounding up or
down, just removing to give me a whole number....

Many Thanks
Davey
 
E

Evertjan.

Davey wrote on 05 dec 2005 in microsoft.public.inetserver.asp.general:
I have some code that divides a number and then prints this number. It
performs a cost rollup basically and then adds a percentage. The code
works fine except that the number returned has many figures afert the
decimal point (as you would expect really)
How can I remove these ? I am not really concerned about rounding up
or down, just removing to give me a whole number....

If you are programming in ASP-vbScript:

formatnumber()

This is very basic, please read up on vbscript internal functions.
 
D

Davey

Hi Evertjan,

I have used the FormatNumber() as you suggest. However, I am also using the
FormatCurrency() to display a cost as currency. This works fine but I get
different currency symbols on different servers !
I have checked the Regional Settings in control on both servers and they are
both set the same, but one displays $, and the other displays £....
Any ideas why this should be ??

Cheers
Davey
 
B

Bob Barrows [MVP]

It's because you are not looking at the correct Regional Settings. When you
look at Regional Settings, you are looking at your OWN settings. ASP runs
under a different user account. The default user account settings is US. You
should consider setting LCID in your application:
http://www.aspfaq.com/show.asp?id=2260
 
E

Evertjan.

Davey wrote on 06 dec 2005 in microsoft.public.inetserver.asp.general:
[please do not toppost on usenet]
I have used the FormatNumber() as you suggest. However, I am also
using the FormatCurrency() to display a cost as currency. This works
fine but I get different currency symbols on different servers !
I have checked the Regional Settings in control on both servers and
they are both set the same, but one displays $, and the other displays
£.... Any ideas why this should be ??

Never use FormatCurrency() in an internet setting, as both the server
regional settings and the clients available fonts have influence.

<% = "€&nbsp;" & FormatNumber(yourGainOrLoss,2) %>

will do what you(?) want.

In general avoid coding that is dependent on regional settings,
though both the decimal and thousands character
are influenced by it in FormatNumber()

€ 1.234,56

or

€ 1,234.56

or ....
 
D

Davey

Thanks Evertjan.

I see what you mean with using the FormatCurrency.

Thankyou for your help
Cheers
Davey


Evertjan. said:
Davey wrote on 06 dec 2005 in microsoft.public.inetserver.asp.general:
[please do not toppost on usenet]
I have used the FormatNumber() as you suggest. However, I am also
using the FormatCurrency() to display a cost as currency. This works
fine but I get different currency symbols on different servers !
I have checked the Regional Settings in control on both servers and
they are both set the same, but one displays $, and the other displays
£.... Any ideas why this should be ??

Never use FormatCurrency() in an internet setting, as both the server
regional settings and the clients available fonts have influence.

<% = "?&nbsp;" & FormatNumber(yourGainOrLoss,2) %>

will do what you(?) want.

In general avoid coding that is dependent on regional settings,
though both the decimal and thousands character
are influenced by it in FormatNumber()

? 1.234,56

or

? 1,234.56

or ....
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top