Solved

formatnumber without comma

Posted on 2011-03-17
5
1,164 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 82

Accepted Solution

by:
Dave Baldwin earned 63 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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 82

Expert Comment

by:Dave Baldwin
Comment Utility
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
Comment Utility
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
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…
This video discusses moving either the default database or any database to a new volume.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

762 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

Need Help in Real-Time?

Connect with top rated Experts

5 Experts available now in Live!

Get 1:1 Help Now