Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

much easier question---formatting

Status
Not open for further replies.

mcpeekj

Vendor
Sep 21, 2001
105
this question is much easier than my last one about sorting (which i have figured out). i've found code for format currency, but how do you format a regular number (ie comma for thousands, etc)?
 
are you looking to round off the numbers? if so
use the round function
Round(expression[, numdecimalplaces])

Dim var, var2
var2 = 123456.123456
var = Round(var2, 2) ' var contains 123456.12
You cannot mandate productivity, you must provide the tools to let people become their best.
-Steve Jobs
admin@onpntwebdesigns.com
 
sory didn't read your ? very well
The currency function does this auto for you
example
<%
Dim MyCurrency
MyCurrency = FormatCurrency(1000000)
Response.Write MyCurrency
'returns $1,000,000.00
%> You cannot mandate productivity, you must provide the tools to let people become their best.
-Steve Jobs
admin@onpntwebdesigns.com
 
FormatNumber would work.

FormatNumber(Expression, NumDigitsAfterDecimal, IncludeLeadingDigit, UseParensForNegativeNumbers, GroupDigit)

<% =FormatNumber(12345.67899, 4) %>

returns

12,345.6790
 
sorry, i have the currency function done, but now i need to format a number like 104591 as 104,591. basically i just need the comma after each 3 digits...
 
with a little adjustment to my other post you could use the MID function
<script language=&quot;vbscript&quot;>
Dim MyCurrency
MyCurrency = FormatCurrency(1000000)
alert MyCurrency
MyCurrency = Mid(MyCurrency, 2)
alert MyCurrency
</script>

this will take out the first char being the $ and return everything after with the commas. You cannot mandate productivity, you must provide the tools to let people become their best.
-Steve Jobs
admin@onpntwebdesigns.com
 
sorry denoxis, didn't see yours. worked wonderfully. one related question though, how can i get it to sort like a number, rather than putting 11,000 after 109,000?
 
you can just write this as well and get the same results
<% var = mid((FormatCurrency(var)),2) %>
and return the same You cannot mandate productivity, you must provide the tools to let people become their best.
-Steve Jobs
admin@onpntwebdesigns.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top