0

I am trying to format currency without the "$" in the beginning of the currency format.

How would I do this? I've tried this but it doesn't work:

Format(e.Row.Cells(7).Text, "{0:n}")

I know that $1,234 is:

Format(e.Row.Cells(7).Text, "Currency")

But I am trying to remove the

$

in front of the currency.

Vivek S.
  • 19,945
  • 7
  • 68
  • 85
J doe
  • 1
  • 1
  • 1
  • If you don't want currency, do not use currency format. Use a numeric format. – GSerg Oct 14 '15 at 23:04
  • There's a setting in VS that changed the currency symbol depending on what you want to appear. If you want nothing at all, then use `Integer` or `Decimal/Double` – MAC Oct 15 '15 at 01:38
  • Possible duplicate of [Format a double value like currency but without the currency sign (C#)](http://stackoverflow.com/questions/1048643/format-a-double-value-like-currency-but-without-the-currency-sign-c) http://stackoverflow.com/a/1048669/1316573 – Daniel Oct 15 '15 at 05:39

2 Answers2

0
Dim value As Double = e.Row.Cells(7).Text 
Dim val2 As String
val2 = (value.ToString("#,#", CultureInfo.InvariantCulture))
e.Row.Cells(7).Text = String.Format(CultureInfo.InvariantCulture, "{0:#,#}", val2)

Do not forget the Imports System.Globalization

eirishainjel
  • 570
  • 7
  • 25
0

TrimStart() function

Dim strVal As String = "$1,234"
strVal = strVal.TrimStart("$")

replace() function

Dim strVal As String = "$1,234"
strVal = strVal.Replace("$",String.Empty)

you can use like this

e.Row.Cells(7).Text = e.Row.Cells(7).Text.TrimStart("$")

or

e.Row.Cells(7).Text = e.Row.Cells(7).Text.Replace("$",String.Empty)
Vivek S.
  • 19,945
  • 7
  • 68
  • 85