Click here to Skip to main content
15,917,795 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
how to split text in textbox and assign the text before + to one variable and text after + to other
Posted

You can use some thing like this:

TextBox txtBox;
int iVariable;
var lstSplit = txtBox.Text.Split('@');

string txtFromTextBox = string.Format("{0}{1}{2}", lstSplit[0], iVariable, lstSplit[1]);
 
Share this answer
 
you can use string.split function here, or substring also by finding the index of + sign
 
Share this answer
 
Try this

C#
string varleft, varRight;
var data = txtBox.Text.Split('+');

varleft = data[0];
varRight = data[1];
 
Share this answer
 
use something like this

C#
string sBeforePlus = "";
                string sAfterPlus = "";
                if (textBoxMain.Text.Contains("+"))
                {
                    string [] arrText = textBoxMain.Text.Split('+');
                    sBeforePlus = arrText[0];
                    sAfterPlus = arrText[1];
                }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900