String formating issue with doubles

  • Thread starter Thread starter Jeremy Kitchen
  • Start date Start date
J

Jeremy Kitchen

Private mFormat As String = "##.##"

Return DirectCast(value, Double).ToString(mFormat) returns "" when
value is 0.0

I would prefer that it return "0". Does anyone have some advice?

Thanks for any help

Jeremy Kitchen
 
Try this fromat string to see if it gives you what you want (I think
it should always show a leading zero before the decimal point).

"#0.##"

================
Clay Burch
Syncfusion, Inc.
 
Jeremy said:
Private mFormat As String = "##.##"

Return DirectCast(value, Double).ToString(mFormat) returns "" when
value is 0.0

I would prefer that it return "0". Does anyone have some advice?

The # indicates an optional number, but you can use 0 for "always a number,
and 0 if there's nothing in there".

Private mFormat As String = "#0.##"

Andrew
 
Hello R. MacDonald,

Hmm... You could enclose the statement in Val

Val(DirectCast(value, Double).ToString(mFormat) )


-- You can do anything with a little bit of 'magination.

-- I've been programming so long, my brain is now software.
 
That doesn't produce a formatted string.
Hello R. MacDonald,

Hmm... You could enclose the statement in Val

Val(DirectCast(value, Double).ToString(mFormat) )


-- You can do anything with a little bit of 'magination.

-- I've been programming so long, my brain is now software.
 
Back
Top