I tried to do it this way in Form1:
private void BtnScrambleText_Click(object sender, EventArgs e)
{
textBox1.Enabled = false;
BtnScrambleText.Enabled = false;
StringBuilder sb = new StringBuilder();
var words = textBox1.Text.Split(new char[] { ' ' });
foreach (var w in words)
{
if (w == " ")
{
sb.Append(w);
continue;
}
ScrambleTextBoxText scrmbltb = new ScrambleTextBoxText(w);
scrmbltb.GetText();
sb.Append(scrmbltb.scrambledWord);
textBox2.AppendText(sb.ToString());
}
}
The new class i have is ScrambleTextBoxText there im just getting a word from the textBox1 scramble it randomaly and then im adding the scrambled word back to the textBox2
But in textBox2 i see all the words in one long string like:
dannyhihellobyethis
There are no spaces at all between the words. I needed it add to textBox2 with the exact spaces it was in textBox1.
If in textBox1 it was for example:
danny hello hi yes two four
moses daniel yellow
So in textBox2 it should be the same line this:
danny hello hi yes two four
moses daniel yellow
With same spaces with two lines down and everything.
Two problems:
no spaces in textBox2
its adding to textBox2 any word i typed in textBox1 but it should add only the words that return from my new class : scrmbltb.scrambledWord
For example if i entered in textBox1 : hi daniel
So in textBox2 it should be : daniel Without the word : hi
Or if in textBox1 it was : daniel hi hello So in textBox2 it will be: daniel hello