Solved

Removing () from decimal value

Posted on 2009-05-18
5
186 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
  • 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 500 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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 …
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…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

706 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