Link to home
Start Free TrialLog in
Avatar of rp
rpFlag for Portugal

asked on

"Hide" if zero

Hi,

Is possible with Numeric Format Strings not show a value field if zero. For ex. i have some values like "0,00" in a report and i need to supress, print blank.

best regards
Avatar of Qlemo
Qlemo
Flag of Germany image

No, you need to implement that yourself by checking the value against zero and replacing with blank.
Avatar of Rgonzo1971
Rgonzo1971

HI,

pls try in excel

yourRange.NumberFormat  = "0.00;-0,00;";

if you want to use string format then use

double posValue = 1234;
double negValue = -1234;
double zeroValue = 0;

string fmt2 = "##;(##)";
string fmt3 = "##;(##);**Zero**";

Console.WriteLine(posValue.ToString(fmt2));  
Console.WriteLine(String.Format("{0:" + fmt2 + "}", posValue));    
// Displays 1234

Console.WriteLine(negValue.ToString(fmt2));  
Console.WriteLine(String.Format("{0:" + fmt2 + "}", negValue));    
// Displays (1234)

Console.WriteLine(zeroValue.ToString(fmt3)); 
Console.WriteLine(String.Format("{0:" + fmt3 + "}", zeroValue));
// Displays **Zero**

Open in new window


refer to
https://msdn.microsoft.com/en-us/library/0c899ak8(v=vs.110).aspx


Regards
ASKER CERTIFIED SOLUTION
Avatar of Imran Javed Zia
Imran Javed Zia
Flag of Pakistan image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial