473,396 Members | 1,785 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Trying to display the decimal...can someone help?

This is what I have working, but I want to display the value like
currency...showing the decimal point and the two points after
it...$8.99.

Thank you!!
Sub AddAcctNums(Source as Object, E as EventArgs)
Dim strControlName As String
Dim i, sum As Int16
sum = 0
For i = 1 To 15
strControlName = "txtAcctNum" & i
Dim TB As TextBox =
CType(Me.FindControl(strControlName), TextBox)
If TB.Text <> "" Then
sum = sum + Val(TB.Text)
End If
Next
txtAcctNumSum.text= sum
End Sub

Shouldn't it look something like this:
txtAcctNumSum.text= sum.Format("{0:c}"), txtAcctNumSum.text)

*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #1
3 904
Try this syntax:

cctNumSum.text = sum.ToString("C")

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
"TN Bella" <ti********@nav-international.com> wrote in message
news:eK**************@TK2MSFTNGP09.phx.gbl...
This is what I have working, but I want to display the value like
currency...showing the decimal point and the two points after
it...$8.99.

Thank you!!
Sub AddAcctNums(Source as Object, E as EventArgs)
Dim strControlName As String
Dim i, sum As Int16
sum = 0
For i = 1 To 15
strControlName = "txtAcctNum" & i
Dim TB As TextBox =
CType(Me.FindControl(strControlName), TextBox)
If TB.Text <> "" Then
sum = sum + Val(TB.Text)
End If
Next
txtAcctNumSum.text= sum
End Sub

Shouldn't it look something like this:
txtAcctNumSum.text= sum.Format("{0:c}"), txtAcctNumSum.text)

*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 18 '05 #2
I'm not sure what's in VB but in C# it's like this:

double sum = GetSomeDoubleValue();
txtMyLable.Text = sum.ToString("N");

Look up for correct formatter for ToString method.
"TN Bella" <ti********@nav-international.com> wrote in message
news:eK**************@TK2MSFTNGP09.phx.gbl...
This is what I have working, but I want to display the value like
currency...showing the decimal point and the two points after
it...$8.99.

Thank you!!
Sub AddAcctNums(Source as Object, E as EventArgs)
Dim strControlName As String
Dim i, sum As Int16
sum = 0
For i = 1 To 15
strControlName = "txtAcctNum" & i
Dim TB As TextBox =
CType(Me.FindControl(strControlName), TextBox)
If TB.Text <> "" Then
sum = sum + Val(TB.Text)
End If
Next
txtAcctNumSum.text= sum
End Sub

Shouldn't it look something like this:
txtAcctNumSum.text= sum.Format("{0:c}"), txtAcctNumSum.text)

*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 18 '05 #3


Okay..I have the decimals and the two values after it, but for some
reason my code is not adding it correctly.

*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
by: Batista, Facundo | last post by:
Here I send it. Suggestions and all kinds of recomendations are more than welcomed. If it all goes ok, it'll be a PEP when I finish writing/modifying the code. Thank you. .. Facundo
5
by: David Greenwood | last post by:
I posted this under 'microsoft.public.sqlserver.client' but got no reply. Any help with this problem would be greatly appreciated --------------------- I developed a database under SQL Server...
2
by: Chris | last post by:
I've just completed a project using the following (Windows XP, python 2.4.1, wxpython 2.6, and pymssql 0.7.3). The program runs great, but after I convert it to an exe (required for this project),...
6
by: Tim Whelan via DotNetMonster.com | last post by:
Hi I am developing an asp.net web application using c# and having trouble trying to display integer values, that I have taken from the database, correctly on my webform textboxes. The values are...
2
by: AMDRIT | last post by:
Hello Everyone, I would like to format the Display Members of a combobox's datasource. Is there a way to apply a format without subclassing the original datasource? For example, given a list of...
4
by: leej | last post by:
Im hoping someone can help me to work out where/what Im missing here. Ive a line in a moderately sized program decimal d1 = Decimal.Parse("0.1"); When I check the result in Visual Studio or...
3
by: JDC | last post by:
Hi all, Is there a recommended way (i.e. not a bodge) to get a GridView to always display decimal numbers using a dot as the decimal separator, regardless of the locale the user is viewing the...
15
by: =?Utf-8?B?VG9tIENvcmNvcmFu?= | last post by:
I've been led to believe by several articles, particularly Eric Gunnerson's C# Calling Code Dynamically, that calling a method dynamically through Reflection was much slower than through a...
1
by: karanbikash | last post by:
Hi , I have a requirement where in I need to display the decimal value of 0.00 as '######.00' SELECT case when DECIMAL(AMT_CHEQUE,31,2) = 0.00 THEN 9999999999999.9999999 ELSE ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.