How to Format a Number in Classic ASP

Posted on 2008-10-03
Last Modified: 2010-04-21

In a Classic ASP application I have a value in a variable that contains a number in bytes (example 2389977645).  I want to display it so as it uses commas.  I have found the FormatNumber() function useless in this area.

Example preferred output: 2,389,977,645

What can you recommend?


Question by:michael4606
LVL 39

Expert Comment

ID: 22634470
vbscript or jscript?
LVL 82

Accepted Solution

hielo earned 65 total points
ID: 22634493
I just tried:
Response.Write( FormatNumber("2389977645",0))

and it works.
LVL 39

Assisted Solution

BrandonGalderisi earned 30 total points
ID: 22634500

wscript.echo formatnumber ("12345",0)

produces 12,345 for me

What does it do for you?

Here's a reference for the command.  You may have to override some regional settings:

Assisted Solution

by:Brad Dobyns, CSM
Brad Dobyns, CSM earned 30 total points
ID: 22634502
It depends on your regional settings but that should work:
<%= FormatNumber(myNumber,0) %>

Open in new window


Author Closing Comment

ID: 31502775
Thanks guys it was my error using the function wrong.  You set me straight.

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

What is an ISAPI filter?   •      It's an assembly (.dll file) that can add or change the way IIS works.   •      They can be enabled globally for your web server or on a site-by-site basis.   When the IIS server receives a request, enabling the ISAPI fi…
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

911 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

19 Experts available now in Live!

Get 1:1 Help Now