?
Solved

Removing () from decimal value

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

Independent Software Vendors: 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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
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 …
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses
Course of the Month13 days, 14 hours left to enroll

807 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