Solved

"Hide" if zero

Posted on 2015-02-19
3
47 Views
Last Modified: 2015-03-06
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
0
Comment
Question by:rflorencio
3 Comments
 
LVL 69

Expert Comment

by:Qlemo
ID: 40618374
No, you need to implement that yourself by checking the value against zero and replacing with blank.
0
 
LVL 50

Expert Comment

by:Rgonzo1971
ID: 40618380
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
0
 
LVL 16

Accepted Solution

by:
Imran Javed Zia earned 500 total points
ID: 40618385
Hi,

you can use following:

d = 0.0;
MessageBox.Show(d.ToString("#.##")

It will show blank space

d = 1.20;
            MessageBox.Show(d.ToString("#.##"));
It will show 1.2

Thanks
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question