?
Solved

Removing () from decimal value

Posted on 2009-05-18
5
Medium Priority
?
233 Views
Last Modified: 2012-05-07
I have a string like this ($3.90). I just want 3.90. I did below. But not sure why when I do the add  the value , when replaced and added, comes out 11.90.00 and I get an error that imput is not in correct format.

How can I remove the () and added this?






lblDiscount.Text = decimal.Parse(lblDiscount.Text.Replace("(","").Replace(")","").Substring(1)).ToString() + decimal.Parse(gi["DiscountAmount"].Text.Substring(1)).ToString();

Open in new window

0
Comment
Question by:Camillia
[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
  • 2
5 Comments
 
LVL 14

Expert Comment

by:jjardine
ID: 24418033
Does this make a difference?

lblDiscount.Text = decimal.Parse(lblDiscount.Text.Replace("(","").Replace(")","").Substring(1)) + decimal.Parse(gi["DiscountAmount"].Text.Substring(1));
0
 
LVL 7

Author Comment

by:Camillia
ID: 24418037
will try in the morning and post back. thanks. Late here.
0
 
LVL 7

Author Comment

by:Camillia
ID: 24421664
nope, gives an error still..
0
 
LVL 14

Accepted Solution

by:
jjardine earned 2000 total points
ID: 24422006
try breaking your two decimal.Parse statements out into seperate calls to see which one is causing the error.

decimal a = decimal.parse(lblDiscount.Text.Replace("(","").Replace(")","").Substring(1));

decimal b = decimal.parse(gi["DiscountAmount"].Text.Substring(1));

This should show which oneis the problem.  What is in DisocuntAmount?
0
 
LVL 7

Author Comment

by:Camillia
ID: 24422577
let me try
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

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

765 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