Format double doesn't work

  • Thread starter Thread starter staeri
  • Start date Start date
S

staeri

If trying to format a value in a GridView with the following function
to be shown with thousand separators. If no value exists it should show
0.

If I send the value = 45000 it is still shown as 45000, not 45.000.
Why?


Function FormatAmount(ByVal value As Object) As String
'Show with thousand separator if not is null, else show 0
Dim strShow As String

If value Is DBNull.Value Then
strShow = "0"
Else
Dim dblAmount As Double = Convert.ToDouble(value)
strShow = Format("{0:#,##0}", dblAmount)
End If

Return strShow
End Function

Can someone please help me?

Regards,

S
 
Use, strShow = String.Format("{0:#,##0}", dblAmount)

instead of, strShow = Format("{0:#,##0}", dblAmount)

if String.Format is not specified, Format function within Strings class is
used.


- Augustin
 
Back
Top