format a s currency ittem in a listview

hi all
how do i format as a currency

 lv.SubItems.Add(objRead("monto").ToString)

tsm
ErnestoAsked:
Who is Participating?
 
it_saigeDeveloperCommented:
In your case you will need to use something like:
lv.SubItems.Add(String.Format("{0:C2}", objRead("monto"))

Open in new window


-saige-
0
 
it_saigeDeveloperCommented:
Use the C2 string format specifier; e.g.:
Public Class Form1
	Private objArray(5) As Object

	Private Sub OnLoad(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
		objArray(0) = 123.0
		objArray(1) = 57.34
		objArray(2) = 67
		objArray(3) = "NaN"
		objArray(4) = 58
		objArray(5) = 0.05

		Dim tempVal As Decimal
		For Each item In objArray
			lv.Items.Add(If(Decimal.TryParse(item, tempVal), tempVal.ToString("C2"), "Not a number"))
		Next
	End Sub
End Class

Open in new window

Produces the following output -Capture.JPG-saige-
0
 
ErnestoAuthor Commented:
lv.SubItems.Add(objRead("monto").ToString("C2", CultureInfo.CurrentCulture))

do not work
0
 
ErnestoAuthor Commented:
Man!!!!
tsm
your a %$#$%#$% Genious!!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.