C# read more lines in text box and edit each line

114 views Asked by At

I have a question?

Here i have the code that reads from one textbox one line. How can I make it to work, that it will read more lines? Not just one.

This code activate with click:

private void b_Execute_Click(object sender, EventArgs e)
{
    string one1 = "NO";
    string one2 = "NO";
    string one3 = "NO";
    string one4 = "NO";
    string one5 = "NO";
    string one6 = "NO";
    string one7 = "NO";
    string one8 = "NO";
    string one9 = "NO";
    string one10 = "NO";
    string one11 = "NO";
    string one12 = "NO";
    string one13 = "NO";
    string one14 = "NO";
    string one15 = "NO";
    string one16 = "NO";

    string[] allInfo = tB_Input.Text.Split(';');
    if (allInfo.Length != 3)
    {
        MessageBox.Show("edit again");
        return;
    }
    string number = allInfo[0];
    string username = allInfo[1];
    string password = allInfo[2];

    //
    if(one1.Checked == true)
        one1_value = "YES";

    //
    if (one2.Checked == true)
        one2_value = "YES";

    //
    if (one3.Checked == true)
        one3_value = "YES";

    //
    if (one4.Checked == true)
        one4_value = "YES";

    //
    if (one5.Checked == true)
        one5_value = "YES";

    //
    if (one6.Checked == true)
        one6_value = "YES";

    //
    if (one7.Checked == true)
        one7_value = "YES";

    //
    if (one8.Checked == true)
        one8_value = "YES";

    //
    if (one9.Checked == true)
        one9_value = "YES";

    //
    if (one10.Checked == true)
        one10_value = "YES";

    //
    if (one11.Checked == true)
        one11_value = "YES";

    //
    if (one12.Checked == true)
        one12_value = "YES";

    //
    if (one13.Checked == true)
        one13_value = "YES";

    //
    if (one14.Checked == true)
        one14_value = "YES";

    //
    if (one15.Checked == true)
        one15_value = "YES";

    //
    if (one16.Checked == true)
        one16_value = "YES";


    if (username.Split('@').Length != 2) 
    {
        MessageBox.Show("error @");
        return;
    }
    string domain = username.Split('@')[1];

    string output = "TAB T=1 \n" +
                    "TAG POS=1 TYPE=INPUT:SUBMIT FORM=ID:aspnetForm ATTR=ID:ctl00_ContentMain_btnAdd \n" +
                    "TAG POS=1 TYPE=INPUT:TEXT FORM=ID:aspnetForm ATTR=ID:ctl00_ContentMain_txtIdentificationNumber CONTENT=" + number + " \n" +
                    "TAG POS=1 TYPE=TD ATTR=TXT:MSISDN: \n" +
                    "TAG POS=1 TYPE=INPUT:CHECKBOX FORM=ID:aspnetForm ATTR=ID:ctl00_ContentMain_chkIsCloudUser CONTENT=YES \n" +
                    "TAG POS=1 TYPE=INPUT:TEXT FORM=ID:aspnetForm ATTR=ID:ctl00_ContentMain_txtFirstName CONTENT=" + username + " \n" +
                    "TAG POS=1 TYPE=INPUT:TEXT FORM=ID:aspnetForm ATTR=ID:ctl00_ContentMain_txtLastName CONTENT=" + username + " \n" +
                    "TAG POS=1 TYPE=INPUT:TEXT FORM=ID:aspnetForm ATTR=ID:ctl00_ContentMain_txtEMail CONTENT=" + username + " \n" +
                    "TAG POS=1 TYPE=INPUT:SUBMIT FORM=ID:aspnetForm ATTR=ID:ctl00_ContentMain_btnOK \n" +
                    "TAG POS=1 TYPE=INPUT:SUBMIT FORM=ID:aspnetForm ATTR=ID:ctl00_ContentMain_btnAddUserPassIdent \n" +
                    "TAG POS=1 TYPE=INPUT:TEXT FORM=ID:aspnetForm ATTR=ID:ctl00_ContentMain_txtUserName CONTENT=" + username + " \n" +
                    "SET !ENCRYPTION NO \n" +
                    "TAG POS=1 TYPE=INPUT:PASSWORD FORM=ID:aspnetForm ATTR=ID:ctl00_ContentMain_txtNewPassword CONTENT=" + password + " \n" +
                    "TAG POS=1 TYPE=INPUT:PASSWORD FORM=ID:aspnetForm ATTR=ID:ctl00_ContentMain_txtConfirmPassword CONTENT=" + password + " \n" +
                    "TAG POS=1 TYPE=INPUT:SUBMIT FORM=ID:aspnetForm ATTR=ID:ctl00_ContentMain_btnOK \n" +
                    "TAG POS=1 TYPE=A ATTR=ID:ctl00_ContentMain_wizard_linkStep3 \n" +
                    "TAG POS=1 TYPE=INPUT:SUBMIT FORM=ID:aspnetForm ATTR=ID:ctl00_ContentMain_btnAdd \n" +
                    "TAG POS=1 TYPE=INPUT:CHECKBOX FORM=ID:aspnetForm ATTR=ID:ctl00_ContentMain_gridUserPasswordIdent_ctl02_chkChecked CONTENT=YES \n" +
                    "TAG POS=1 TYPE=SELECT FORM=ID:aspnetForm ATTR=ID:ctl00_ContentMain_listService CONTENT=%2 \n" +
                    "TAG POS=1 TYPE=INPUT:CHECKBOX FORM=ID:aspnetForm ATTR=ID:ctl00_ContentMain_chkDissableLoginToAllApps CONTENT=YES \n" +
                    //
                    "TAG POS=1 TYPE=INPUT:CHECKBOX FORM=ID:aspnetForm ATTR=ID:ctl00_ContentMain_gridServices_ctl02_chkSelected CONTENT=" + one1_value + "\n" +
                    //
                    "TAG POS=1 TYPE=INPUT:CHECKBOX FORM=ID:aspnetForm ATTR=ID:ctl00_ContentMain_gridServices_ctl03_chkSelected CONTENT=" + one2_value + "\n" +
                    //
                    "TAG POS=1 TYPE=INPUT:CHECKBOX FORM=ID:aspnetForm ATTR=ID:ctl00_ContentMain_gridServices_ctl04_chkSelected CONTENT=" + one3_value + "\n" +
                    //
                    "TAG POS=1 TYPE=INPUT:CHECKBOX FORM=ID:aspnetForm ATTR=ID:ctl00_ContentMain_gridServices_ctl05_chkSelected CONTENT=" + one4_value + "\n" +
                    //
                    "TAG POS=1 TYPE=INPUT:CHECKBOX FORM=ID:aspnetForm ATTR=ID:ctl00_ContentMain_gridServices_ctl06_chkSelected CONTENT=" + one5_value + "\n" +
                    //
                    "TAG POS=1 TYPE=INPUT:CHECKBOX FORM=ID:aspnetForm ATTR=ID:ctl00_ContentMain_gridServices_ctl07_chkSelected CONTENT=" + one6_value + "\n" +
                    //
                    "TAG POS=1 TYPE=INPUT:CHECKBOX FORM=ID:aspnetForm ATTR=ID:ctl00_ContentMain_gridServices_ctl08_chkSelected CONTENT=" + one7_value + "\n" +
                    //
                    "TAG POS=1 TYPE=INPUT:CHECKBOX FORM=ID:aspnetForm ATTR=ID:ctl00_ContentMain_gridServices_ctl09_chkSelected CONTENT=" + one8_value + "\n" +
                    //
                    "TAG POS=1 TYPE=INPUT:CHECKBOX FORM=ID:aspnetForm ATTR=ID:ctl00_ContentMain_gridServices_ctl10_chkSelected CONTENT=" + one9_value + "\n" +
                    //
                    "TAG POS=1 TYPE=INPUT:CHECKBOX FORM=ID:aspnetForm ATTR=ID:ctl00_ContentMain_gridServices_ctl11_chkSelected CONTENT=" + one10_value + "\n" +
                    //
                    "TAG POS=1 TYPE=INPUT:CHECKBOX FORM=ID:aspnetForm ATTR=ID:ctl00_ContentMain_gridServices_ctl12_chkSelected CONTENT=" + one11_value + "\n" +
                    //
                    "TAG POS=1 TYPE=INPUT:CHECKBOX FORM=ID:aspnetForm ATTR=ID:ctl00_ContentMain_gridServices_ctl13_chkSelected CONTENT=" + one12_value + "\n" +
                    //
                    "TAG POS=1 TYPE=INPUT:CHECKBOX FORM=ID:aspnetForm ATTR=ID:ctl00_ContentMain_gridServices_ctl14_chkSelected CONTENT=" + one13_value + "\n" +
                    //
                    "TAG POS=1 TYPE=INPUT:CHECKBOX FORM=ID:aspnetForm ATTR=ID:ctl00_ContentMain_gridServices_ctl15_chkSelected CONTENT=" + one14_value + "\n" +
                    //
                    "TAG POS=1 TYPE=INPUT:CHECKBOX FORM=ID:aspnetForm ATTR=ID:ctl00_ContentMain_gridServices_ctl16_chkSelected CONTENT=" + one15_value + "\n" +
                    //
                    "TAG POS=1 TYPE=INPUT:CHECKBOX FORM=ID:aspnetForm ATTR=ID:ctl00_ContentMain_gridServices_ctl17_chkSelected CONTENT=" + one16_value + "\n" +
                    "TAG POS=1 TYPE=INPUT:BUTTON FORM=ID:aspnetForm ATTR=ID:ctl00_ContentMain_btnSelectSubjectCompany \n" +
                    "FRAME F=1 \n" +
                    "TAG POS=1 TYPE=INPUT:TEXT FORM=ID:aspnetForm ATTR=ID:ctl00_ContentMain_txtName CONTENT=" + domain + " \n" +
                    "TAG POS=1 TYPE=INPUT:SUBMIT FORM=ID:aspnetForm ATTR=ID:ctl00_ContentMain_btnSearch \n" +
                    "TAG POS=1 TYPE=A ATTR=TXT:" + domain + " \n" +
                    "TAG POS=1 TYPE=INPUT:SUBMIT FORM=ID:aspnetForm ATTR=ID:ctl00_ContentMain_btnOK \n" +
                    "TAG POS=1 TYPE=A ATTR=TXT:Uporabniki \n";
    richTextBox1.Text = output;
    Clipboard.SetText(output);        

Can someone help me with this problem?

1

There are 1 answers

0
Adam On BEST ANSWER
for( int i = 0; i < textbox.Lines.Length; i++ )
   readanddosomething();

Textbox.Lines is the method you want to use. Allows you to access the lines in a textbox via....Textbox.Lines[index]