Link to home
Create AccountLog in
Avatar of jnsimex
jnsimex

asked on

sum values in a textbox C#

C# Visual Studio 2005

I have a textbox that a person enters the packaging details in i.e. 1 x 500, 2 x 50

I need to sum the total of the text entered into the textbox, which in this case would be 600.

how should I approach this problem?
Avatar of p_davis
p_davis

is comma delimited like you show in your question or is that to denote two textboxes?
also will you need to parse the math statement 1x500 or is there a quantity box that you multiply against another number
Avatar of jnsimex

ASKER

hi pdavis, it is comma delimited.

As for your second question, i will need to parse 1x500 = 500 and then add it to the second math statement 2x50 = 100 for a total sum of 600.
will there be more than one operation per comma?

like

1 + 5 x 500, 2 x 50


or

1 x 500 x 2, 3 x 10

etc...
ASKER CERTIFIED SOLUTION
Avatar of p_davis
p_davis

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of jnsimex

ASKER

Only one operation per comma

Thanks for providing the code snippet. I will test later on today and let you know the results.
SOLUTION
Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Avatar of jnsimex

ASKER

Thank you both for the coding.

They both worked equally well.