Solved

formatnumber without comma

Posted on 2011-03-17
5
1,185 Views
Last Modified: 2012-05-11
Hi,

For some strange reason a banking system Im sending a number to will not accept commas.
so if I send 1,200.50 it fails
However if I send the number without sending it as formatnumber(number,2) it also fails because the decimals arent correct eg theyd be 1200.5
Basically it needs to be a number with correct decimals and no commas for values > 999
Any ideas to get around this please?
0
Comment
Question by:lgreally
  • 2
  • 2
5 Comments
 
LVL 83

Accepted Solution

by:
Dave Baldwin earned 63 total points
ID: 35161764
From W3Schools demo page.  http://www.w3schools.com/vbScript/func_formatnumber.asp
<html>
<body>

<script type="text/vbscript">

document.write(FormatNumber(20000,2,0,0,0) & "<br />")
document.write(FormatNumber(20000,2))

</script> 

</body>
</html>

Open in new window

0
 

Author Comment

by:lgreally
ID: 35161790
Thanks Dave
I implemented
mAmount = FormatNumber(mAmount,2,0,0,0)
mAmount = FormatNumber(mAmount,2)

However, I still get 1,350.50 ie including a comma (which fails)
0
 
LVL 2

Assisted Solution

by:rhawk
rhawk earned 62 total points
ID: 35161860
If you get the right number (the ending 0) but want to rip out the comma then add this:
mAmount=Replace(mAmount,",","")
Take the good number with the comma and pull it out.
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 35161919
I left the second example in there just for the comparison.  All you want to actually use is "mAmount = FormatNumber(mAmount,2,0,0,0)".  Keeping the second version just puts it back the way it was.
0
 

Author Closing Comment

by:lgreally
ID: 35161926
I'd been reluctant to try the replace function thinking it would be picked up as a string but the banking system seems to like it.

Just to clarify my code is:

mAmount = FormatNumber(mAmount,2,0,0,0)
mAmount = FormatNumber(mAmount,2)

if instr(1,cstr(mAmount),",") then
    mAmount = replace(mAmount,",","")
end if

Thanks guys
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question