Solved

formatnumber without comma

Posted on 2011-03-17
5
1,199 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
[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
  • Learn & ask questions
  • 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

Get HTML5 Certified

Want to be a web developer? You'll need to know HTML. Prepare for HTML5 certification by enrolling in July's Course of the Month! It's free for Premium Members, Team Accounts, and Qualified Experts.

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…

630 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