logo
g Text Version
Beauty & Self
Books & Music
Career
Computers
Education
Family
Food & Wine
Health & Fitness
Hobbies & Crafts
Home & Garden
Money
News & Politics
Relationships
Religion & Spirituality
Sports
Travel & Culture
TV & Movies

dailyclick
Bored? Games!
Nutrition
Postcards
Take a Quiz
Rate My Photo

new
Painting
Heart Disease
Horror Literature
Dating
Hiking & Backpacking
SF/Fantasy Books
Healthy Foods


dailyclick
All times in EST

Full Schedule
g
g ASP Site

BellaOnline's ASP Editor

g

3-digits Formatting a String

Guest Author - Linawaty


Sometimes, you want to format a string into separated 3-digits to make it easier to read. This is the function to do it. You just need to paste it somewhere in your ASP code (or include it) and call it from anywhere in your code.

Scenario:
input = string eg. "1234567890"
output = string eg. "1,123,456,789"

Function:

function SenFormat(a)
org=a
if len(org)>3 then
do while len(org)>3
sema=left(org,len(org)-3)
semb=right(org,3)
semNew= "," & semb & semNew
org=sema
loop
SenFormat=sema & semNew
else
SenFormat=org
end if
'this is where your customization goes
end function

Of course you can customize the script a bit.

Example1:
Scenario1: Change the separator
input = string eg. "1234567890"
output = string eg. "1.123.456.789"

Change to function:
Replace the "," with "."
semNew= "." & semb & semNew

Example2:
Scenario2: Add the currency sign
input = string eg. "1234567890"
output = string eg. "Rp 1.123.456.789"

Change to function:
Add this code line below the "'this is where your customization goes":
SenFormat = "Rp " & SenFormat
where "Rp" is a currency sign here, you can alter it to suit your currency, such as dollar($), pound(), yen().

This site needs an editor - click to learn more!

Add 3%2Ddigits+Formatting+a+String to Twitter Add 3%2Ddigits+Formatting+a+String to Facebook Add 3%2Ddigits+Formatting+a+String to MySpace Add 3%2Ddigits+Formatting+a+String to Del.icio.us Digg 3%2Ddigits+Formatting+a+String Add 3%2Ddigits+Formatting+a+String to Yahoo My Web Add 3%2Ddigits+Formatting+a+String to Google Bookmarks Add 3%2Ddigits+Formatting+a+String to Stumbleupon Add 3%2Ddigits+Formatting+a+String to Reddit




RSS | Related Articles | Editor's Picks Articles | Top Ten Articles | Previous Features | Site Map


For FREE email updates, subscribe to the ASP Newsletter


Past Issues


print
Printer Friendly
bookmark
Bookmark
tell friend
Tell a Friend
forum
Forum
email
Email Editor


Content copyright © 2013 by Linawaty. All rights reserved.
This content was written by Linawaty. If you wish to use this content in any manner, you need written permission. Contact BellaOnline Administration for details.

g


g features
Best uses for RSS

RSS and its future.

Force Download Dialog box with ASP

Archives | Site Map

forum
Forum
email
Contact

Past Issues
memberscenter


vote
Poetry
Daily
Weekly
Monthly
Less than Monthly



BellaOnline on Facebook
g


| About BellaOnline | Privacy Policy | Advertising | Become an Editor |
Website copyright © 2013 Minerva WebWorks LLC. All rights reserved.


BellaOnline Editor