?
Solved

how can I format a negative number to show with braces without dollar symbol ?

Posted on 2009-04-16
6
Medium Priority
?
317 Views
Last Modified: 2012-05-06
how can I format a negative number to show with braces without dollar symbol ?
eg: -1 should be shown as (1). If I format this as currency it shows ($1). I do not want the currency symbol.
0
Comment
Question by:tech_question
  • 4
  • 2
6 Comments
 
LVL 6

Expert Comment

by:DanielWillmott
ID: 24162835
Example:

        double i = 1234.50;
        double j = -1234.50;
 
        Label1.Text = i.ToString("#,#.00;(#,#.00)"); // outputs 1234.50
        Label2.Text = j.ToString("#,#.00;(#,#.00)"); // outputs (1234.50)

Open in new window

0
 

Author Comment

by:tech_question
ID: 24167356
thanks - do you know how can I get this done in reporting services ? it did work in C# in an .aspx page but I am unable to get into work in reporting services ? ToString("#,#.00;(#,#.00)")
0
 
LVL 6

Expert Comment

by:DanielWillmott
ID: 24167692
Is this for a field in Reporting Services?
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:tech_question
ID: 24167789
yes.  =Fields!QUANTITY.Value.ToString("#,#.00;(#,#.00)")

this statement gives me an error in runtime.
0
 
LVL 6

Expert Comment

by:DanielWillmott
ID: 24167848
That would be different if that is the case. I would just use an IIF there...
=IIf(Fields!NumberField.Value < 0, "(" & Fields!NumberField.Value & ")", Fields!NumberField.Value)

Open in new window

0
 
LVL 6

Accepted Solution

by:
DanielWillmott earned 2000 total points
ID: 24167866
specifically in your case then:

=IIf(Fields!QUANTITY.Value < 0, "(" & Fields!QUANTITY.Value & ")", Fields!QUANTITY.Value)

Open in new window

0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

862 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