M
Mojomarc
I'm new still fairly new to programming, and working in C#. I've
written a small application as practice that takes in a string of
numbers, converts them to a decimal (subtotal), and based on another
text entry (txtCustomerType.Text) elsewhere on my form does some
calculations with that decimal (if the txtCustomerType.Text = "R", for
example, instead of getting no discount, the subtotal should reflect a
10% discount). The decimal is supposed to be formatted as currency
with respect to the form, so at the end of the whole calculation I put
this line in:
txtSubtotal.Text = subtotal.ToString("c");
So far, so good, and it builds and runs fine one time through. However
if I want to see how the same value would be calculated with a changed
customer type, I'm stuck with a currency-formated string for my
txtSubtotal.Text, and because all the calculations are based on
whatever value is in subtotal, it breaks because I no longer have a
decimal in there but a string.
I've tried noodling around with a bunch of different things including
trying to trim out the "$" character, but nothing seems to work to
convert it back to a plain string of numbers so I can run my
calculation over and over again. I'm sure this is a really basic
question, but I'm really stuck on this. Help!
written a small application as practice that takes in a string of
numbers, converts them to a decimal (subtotal), and based on another
text entry (txtCustomerType.Text) elsewhere on my form does some
calculations with that decimal (if the txtCustomerType.Text = "R", for
example, instead of getting no discount, the subtotal should reflect a
10% discount). The decimal is supposed to be formatted as currency
with respect to the form, so at the end of the whole calculation I put
this line in:
txtSubtotal.Text = subtotal.ToString("c");
So far, so good, and it builds and runs fine one time through. However
if I want to see how the same value would be calculated with a changed
customer type, I'm stuck with a currency-formated string for my
txtSubtotal.Text, and because all the calculations are based on
whatever value is in subtotal, it breaks because I no longer have a
decimal in there but a string.
I've tried noodling around with a bunch of different things including
trying to trim out the "$" character, but nothing seems to work to
convert it back to a plain string of numbers so I can run my
calculation over and over again. I'm sure this is a really basic
question, but I'm really stuck on this. Help!