Customer Login  .   Webmail Login  .   About Us  .   Contact Us
Go to: Articles List

Formatting Numbers Part 3 : Percentages

The function you need to format percentages is FormatPercent. It is very easy to use and has been outlined and explained below:

FormatPercent(NumToBeFormatted[, NumOfDigitsAfterDecimal, IncludeLeadingDigit, UseParensForNegativeNumbers])
- returns a formatted percentage from the number specified with the appropriate number of digits specified after the decimal and a trailing '%' sign.
- the first parameter is the only one that is required, although I recommend that you use at least include the second parameter.
- the last two parentheses are tristate values which means you need to specify a -1 for true, 0 for false, or -2 to use the computers regional settings.
- the IncludeLeadingDigit parameter is used to specify whether or not you want a leading zero to be displayed when the number is a fractional value.
- the UseParensForNegativeNumbers parameter is pretty self explanatory, if set to true it will put parentheses around negative numbers.

Example:

var1 = 5.4333
var2 = .823
Response.Write("var1 formatted = " & FormatPercent(var1, 2, -1, -1) & "<br>")
Response.Write("var2 formatted = " & FormatPercent(var2, 1, -1, -1))

Result:
var1 formatted = 543.33%
var2 formatted = 82.3%

Shared Hosting
Rookie
Pro
Advanced
Dedicated Servers
BASE
BUSINESS
ENTERPRISE
Why Choose Brinkster?
Radical Support
Brinkster Datacenter
Brinkster Network
Corporate Social Responsibility
90 Day Money Back Guarantee
Unsurpassed Value
Client Testimonials
Additional Features
Antivirus
Merchant Account
E-Commerce
Live Chat Communicator
Free Firewall
Website Builder
Free Web Hosting
Support
General Support
Codebank Search
Forums
Articles
Click here for Brinkster Live Chat
Home   Domains   Shared Hosting   Dedicated Hosting   Partner   Support   About Us    Contact Us   Webmail
Copyright © Brinkster Communications Corporation All Rights Reserved. Privacy Policy & Legal