Solved

Removing () from decimal value

Posted on 2009-05-18
5
210 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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Suggested Solutions

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…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

777 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