Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Display Number (Amount) Properly

Reply
 
Old 08-22-2008   #1 (permalink)
Leona Leal Educator


 
 

Display Number (Amount) Properly

Kind of new at this so I do not know all of the correct script keywords.

How do you display an amount as currency properly when the number is 5.6

I have Response.Write "$" & Amount & " is what you owe the school district"

Sorry, I would like for it to display as $5.60. It currrently display as
$5.6 I have not done enough scripting to learn how to do this. Naturally
when the amount does not end in 0 it works.

Thank You in Advance

Grandma Leona

My System SpecsSystem Spec
Old 08-22-2008   #2 (permalink)
Tom Lavedas


 
 

Re: Display Number (Amount) Properly

On Aug 22, 7:54 am, Leona Leal Educator
<LeonaLealEduca...@xxxxxx> wrote:
Quote:

> Kind of new at this so I do not know all of the correct script keywords.
>
> How do you display an amount as currency properly when the number is 5.6
>
> I have Response.Write "$" & Amount & " is what you owe the school district"
>
> Sorry, I would like for it to display as $5.60. It currrently display as
> $5.6 I have not done enough scripting to learn how to do this. Naturally
> when the amount does not end in 0 it works.
>
> Thank You in Advance
>
> Grandma Leona
try ...

Response.Write "$" & formatnumber(Amount, 2, true, true, true) _
& " is what you owe the school district"

Tom Lavedas
===========
http://members.cox.net/tglbatch/wsh/
My System SpecsSystem Spec
Old 08-22-2008   #3 (permalink)
Dr J R Stockton


 
 

Re: Display Number (Amount) Properly

In microsoft.public.scripting.vbscript message <45B8F8CD-884A-4129-8D22-
47AC06AC518D@xxxxxx>, Fri, 22 Aug 2008 04:54:01, Leona Leal
Educator <LeonaLealEducator@xxxxxx> posted:
Quote:

>Kind of new at this so I do not know all of the correct script keywords.
>
>How do you display an amount as currency properly when the number is 5.6
>
>I have Response.Write "$" & Amount & " is what you owe the school district"
>
>Sorry, I would like for it to display as $5.60. It currrently display as
>$5.6 I have not done enough scripting to learn how to do this. Naturally
>when the amount does not end in 0 it works.
If you are doing arithmetic, even addition, with numbers like 5.6 / 5.60
then results may not be accurate, because such numbers cannot be stored
exactly as IEEE Doubles. Try document.write 0.01 + 0.06 - 0.07 for
example. Commonly, display rounding will give the right value; but it
may be unwise to rely on that. You don't want something that usually
works.

Do your calculations in integer pence, and if you use no fractional
pence all will be exact. Convert the result X to String - CStr(X) -,
add leading zeroes if needed to make the length at least three, insert a
decimal point, and display.

--
(c) John Stockton, nr London UK. ?@merlyn.demon.co.uk DOS 3.3 6.20 ; WinXP.
Web <URL:http://www.merlyn.demon.co.uk/> - FAQqish topics, acronyms & links.
PAS EXE TXT ZIP via <URL:http://www.merlyn.demon.co.uk/programs/00index.htm>
My DOS <URL:http://www.merlyn.demon.co.uk/batfiles.htm> - also batprogs.htm.
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Display does not align text properly Vista General
Some desktop icons won't display properly Vista General
Re: number of recent programs to display - How to clear? Vista General
Re: number of recent programs to display - How to clear? Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46