Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 25th, 2005, 03:59 AM
Authorized User
 
Join Date: Jun 2003
Posts: 12
Thanks: 1
Thanked 0 Times in 0 Posts
Default FormatNumber Problem please help

I can't manage to find a way how to format numbers like below:

Original Number: 65000
I want it formatted this way: 65,000

I tried various ways using the FormatNumber function but I can't get exactly what I want. I want to display a comma after the third number from the right. It must be a comma and not a point.

Can anyone please help me

Thanks You
 
Old October 25th, 2005, 12:22 PM
Authorized User
 
Join Date: Jan 2005
Posts: 54
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello, Ivany!

I guess I know what is going on... I had exactly the same kind of problem sometime ago!! ;)

Have a look at http://p2p.wrox.com/topic.asp?TOPIC_ID=35390 !

Cheers,
fskilnik

 
Old October 25th, 2005, 06:31 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

;;;I want to display a comma after the third number from the right


   function alterNum(numVar)
      alterNum = replace(numVar,"000",",000")
   end function

   dim num
   num = "65000"
   response.write alterNum(num)

Wind is your friend
Matt
 
Old November 2nd, 2005, 08:12 AM
Authorized User
 
Join Date: Jan 2005
Posts: 54
Thanks: 0
Thanked 0 Times in 0 Posts
Default


Hello Ivany and mat41,

I created another function, similar to mat41´s, but a bit more general. I hope you find it useful:

function USCurrency(currValue)
 USCurrency=FormatCurrency(FormatNumber((currValue) , 2, -2, -2, -2))
End function

When you have (say) the currValue= 76543,21 (21 is decimal) this function will get 76,543.21 (thousands and decimals separators)

Important: don´t forget to write "LCID = 1033" (for US formats) at the top of the page where this function is defined!

Cheers,
fskilnik









Similar Threads
Thread Thread Starter Forum Replies Last Post
FormatNumber Problem please help ivanv Classic ASP Databases 1 October 26th, 2005 08:16 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.