Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Our Top 10 Tips for Classic ASP : Page 8

Tidy up your server-side programming techniques with these 10 great tricks for classic ASP.


advertisement
Formatting Numbers for Display

One unexpected feature of VBScript for VB programmers making the change to ASP is that the familiar Format function is missing. So how do you format numbers the way you want them instead of the way they are stored in the database--for example, as a percentage, as a currency, or even with decimal places? Use the code in this example which shows you how to use the new FormatXXXXX functions that replace the VB Format function.

Question:
On a particular page in the application I'm developing, I'd like to display some numbers, in ####.#### format. How do I go about doing that in ASP?



Answer:
Use the FormatNumber function in VBScript. This returns an expression formatted as a number.

Syntax: FormatNumber(Expression [,NumDigitsAfterDecimal [,IncludeLeadingDigit [,UseParensForNegativeNumbers [,GroupDigits]]]])

For example, FormatNumber("123.45",4) would return 123.4500

Check the VBScript help at http://msdn.microsoft.com/scripting for more info.



Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date