Split a text box in one form to multiple labels into another form
<p>I need to send information input into a text box in one form to labels in another form. I have it split at the moment, but since there is only one split If the user enters more that one space in the text box (lets say First, Middle, Last) the second form will only show first and middle. I need to split it twice times just in case the user does enter two spaces. </p>

<p>This is the code I have at the moment.</p>

<pre><code>    //Name Split
        if (strTextBox.Contains (' '))
        {
            var fullname = strTextBox;
            var names = fullname.Split(' ');
            // perhaps TODO -- there could be a middle name/initial
            label3.Text = names[0]; // first
            label5.Text = names[1]; // middle initial
        }

        else //without this conditional if a user only enters a first name the app fails.
            label3.Text = strTextBox;
</code></pre>

<p>I have been trying t figure this out but I cannot seem to wrap my head around it. This code compiles fine but I cannot get it to show the last name.</p>

<p>Here is my code:</p>

<pre><code>    //Name Split
        if (strTextBox.Contains (' '))
        {
            var fullname = strTextBox;
            var names = fullname.Split(' ');
            // perhaps TODO -- there could be a middle name/initial
            label3.Text = names[0]; // first
            label5.Text = names[1]; // middle initial
        }
        else if (strTextBox.Contains (" " + " "))
        {
            var FN = strTextBox;
            var N = FN.Split(' ');
            label3.Text = N[0] + " " + N[1]; // first and middle
            label5.Text = N[2]; // last name
        }
        else //incase only a first name is entered
            label3.Text = strTextBox;
    }
</code></pre>

<p>Any Suggestions?</p>

<p>I already have passing the information to the next form, I just need to fix this conditional so I can get all three names just incase the user does have first, middle, last.</p>
