|
 |
aspx thread: Formatting Currency
Message #1 by "Hugh McLaughlin" <hugh@k...> on Tue, 21 May 2002 23:52:38
|
|
Hello everyone and thanks for your help in advance. I have an
application that takes values in via a textbox, then performs
calculations, and creates an output that should be formatted as
currency. My problem is, I do not know how to change the format to a
currency, rounding to the nearest penny, and formatting with dollar
signs, commas, and decimals. Any help would be greatly appreciated.
Thanks.
Message #2 by "Mingkun Goh" <mangokun@h...> on Wed, 22 May 2002 05:58:18
|
|
lblMoney.Text = Format(TextBox1.Text, "$###,###,###,##0.00")
> Hello everyone and thanks for your help in advance. I have an
a> pplication that takes values in via a textbox, then performs
c> alculations, and creates an output that should be formatted as
c> urrency. My problem is, I do not know how to change the format to a
c> urrency, rounding to the nearest penny, and formatting with dollar
s> igns, commas, and decimals. Any help would be greatly appreciated.
T> hanks.
Message #3 by "Dave Rezoski" <daverezoski@h...> on Wed, 22 May 2002 05:46:56 +0000
|
|
Here you go... vb.net style for use in an aspx page.
Imports System.Globalization.NumberFormatInfo
Public Class ConvertToCurrency
Inherits System.Web.UI.Page
Public myInt As Double = 12.3456
Public myRoundedInt As Double
Public myCurrencyValue As String
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
myRoundedInt = Math.Round(myInt, 2)
myCurrencyValue = myInt.ToString("C")
Response.Write(myCurrencyValue)
End Sub
End Class
HTH
Have a nice day.
----Original Message Follows----
From: "Hugh McLaughlin" <hugh@k...>
Reply-To: "ASP+" <aspx@p...>
To: "ASP+" <aspx@p...>
Subject: [aspx] Formatting Currency
Date: Tue, 21 May 2002 23:52:38
Hello everyone and thanks for your help in advance. I have an
application that takes values in via a textbox, then performs
calculations, and creates an output that should be formatted as
currency. My problem is, I do not know how to change the format to a
currency, rounding to the nearest penny, and formatting with dollar
signs, commas, and decimals. Any help would be greatly appreciated.
Thanks.
_________________________________________________________________
MSN Photos is the easiest way to share and print your photos:
http://photos.msn.com/support/worldwide.aspx
Message #4 by "Dave Rezoski" <daverezoski@h...> on Wed, 22 May 2002 05:57:03 +0000
|
|
lblMyMoney.Text = FormatCurrency(TextBox1.Text)
----Original Message Follows----
From: "Hugh McLaughlin" <hugh@k...>
Reply-To: "ASP+" <aspx@p...>
To: "ASP+" <aspx@p...>
Subject: [aspx] Formatting Currency
Date: Tue, 21 May 2002 23:52:38
Hello everyone and thanks for your help in advance. I have an
application that takes values in via a textbox, then performs
calculations, and creates an output that should be formatted as
currency. My problem is, I do not know how to change the format to a
currency, rounding to the nearest penny, and formatting with dollar
signs, commas, and decimals. Any help would be greatly appreciated.
Thanks.
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp.
Message #5 by Imar Spaanjaars <Imar@S...> on Wed, 22 May 2002 08:09:15 +0200
|
|
Another option is to use the ToString method built in in all .NET objects.
This methods accepts a format specifier, like "C" which will convert a
number to $1,200.00 for example.
Example: 1200.ToString("C") will output =80 1.200,00 at my computer, as the
ToString method is culture aware.
Check out Format Specifiers in the documentation.
HtH
Imar
At 05:57 AM 5/22/2002 +0000, you wrote:
>lblMyMoney.Text =3D FormatCurrency(TextBox1.Text)
>
>
>----Original Message Follows----
>From: "Hugh McLaughlin" <hugh@k...>
>Reply-To: "ASP+" <aspx@p...>
>To: "ASP+" <aspx@p...>
>Subject: [aspx] Formatting Currency
>Date: Tue, 21 May 2002 23:52:38
>
>Hello everyone and thanks for your help in advance. I have an
>application that takes values in via a textbox, then performs
>calculations, and creates an output that should be formatted as
>currency. My problem is, I do not know how to change the format to a
>currency, rounding to the nearest penny, and formatting with dollar
>signs, commas, and decimals. Any help would be greatly appreciated.
>Thanks.
|
|
 |