• Status: Solved
• Priority: Medium
• Security: Public
• Views: 1215

# formatnumber without comma

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
lgreally
• 2
• 2
2 Solutions

Fixer of ProblemsCommented:
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>
``````
0

Author Commented:
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

Commented:
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

Fixer of ProblemsCommented:
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 Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.