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.Val ue;
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
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.Val
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
excellent questions idle maind. can't helkp without knowing these
ASKER
yes and yes, those formats will always be the same
ASKER
constant values; sorry new to c#
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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);
string modelpricemonth = "8700199.9912";
int period = modelpricemonth.IndexOf(".
string variableModel = modelpricemonth.Substring(
string variablePrice = modelpricemonth.Substring(
string variableMonth = modelpricemonth.Substring(
Will there ALWAYS be two digits after the decimal place?