Link to home
Start Free TrialLog in
Avatar of fwsteal
fwsteal

asked on

string help in asp.net

I've got 3 sets of radio buttons on an asp.net page and need to parse out the string that is returned when a user makes a selection.

8700  $199.99  12
7105  $99.99   12
7290  $49.99   12

The value for each looks like: 8700199.9912
-------------------------------------------------

code:
string modelpricemonth;
string variableModel; // = 8700
string variablePrice; // = 199.99
string variableMonth; // = 12

modelpricemonth = ModelType.SelectedItem.Value;
LabelSummary.Text = modelpricemonth; //8700199.9912

LabelModel.text = variableModel;
LabelPrice.text = "$" + variablePrice;
LabelMonths.text = variableMonth;
-----------------------------------------------------

How do I get this result?

LabelModel.Text = 8700
LabelPrice.Text = $199.99
LabelMonths.Text = 12

thanks
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Will the model ALWAYS be four digits?

Will there ALWAYS be two digits after the decimal place?
excellent questions idle maind. can't helkp without knowing these
Avatar of fwsteal
fwsteal

ASKER

yes and yes, those formats will always be the same
Avatar of fwsteal

ASKER

constant values; sorry new to c#
ASKER CERTIFIED SOLUTION
Avatar of Fernando Soto
Fernando Soto
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You could also do...

            string modelpricemonth = "8700199.9912";
            int period = modelpricemonth.IndexOf(".");
            string variableModel = modelpricemonth.Substring(0,4);            
            string variablePrice = modelpricemonth.Substring(4, period - 4 + 3);
            string variableMonth = modelpricemonth.Substring(period + 3);