[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Removing () from decimal value

Posted on 2009-05-18
5
Medium Priority
?
234 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

656 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