Solved

"Hide" if zero

Posted on 2015-02-19
3
44 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 68

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 49

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
detecting  the added row index in a datagridview 3 62
vb.net checkbox 7 41
Reset asp.net login password 4 34
VB.NET 2008 Populate DataModel with DataTable 44 13
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

863 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now