Solved

# formatnumber without comma

Posted on 2011-03-17
1,199 Views
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
Question by:lgreally
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points
• 2
• 2

LVL 83

Accepted Solution

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>
``````
0

Author Comment

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

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

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

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

Question has a verified solution.

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

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
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…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
###### Suggested Courses
Course of the Month3 days, 23 hours left to enroll