Solved

"Hide" if zero

Posted on 2015-02-19
3
49 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 70

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 52

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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

624 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