Format double doesn't work

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
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top