4
Answers

Simplify Loop

Blake Arnold

Blake Arnold

17y
2.6k
1
I have this piece of code that i would like to simplify because I know that i will be adding more checkboxes in the future. Can any one help me to simplify this? Also, I already declared the string strSubscription in above code.

        //Assign database name to strings
        if (chbAll1t60.Checked == true)
        {
            strSubscription += "xXpoOFAd";
            if (chbAll60t70.Checked == true)
            {
                strSubscription += ":wE9z4HjJ";
            }
            else
            {
                if (chbHor1t60.Checked == true)
                {
                    strSubscription += ":yRczF320";
                }
                else
                {
                    if (chbHor60t70.Checked == true)
                    {
                        strSubscription += ":8qz1ExKb";
                    }
                }
            }
        }
        else
        {
            if (chbAll60t70.Checked == true)
            {
                strSubscription += "wE9z4HjJ";
                if (chbHor1t60.Checked == true)
                {
                    strSubscription += ":yRczF320";
                }
                else
                {
                    if (chbHor60t70.Checked == true)
                    {
                        strSubscription += ":8qz1ExKb";
                    }
                }
            }
            else
            {
                if (chbHor1t60.Checked == true)
                {
                    strSubscription += "yRczF320";
                    if (chbHor60t70.Checked == true)
                    {
                        strSubscription += ":8qz1ExKb";
                    }
                }
                else
                {
                    if (chbHor60t70.Checked == true)
                    {
                        strSubscription += "8qz1ExKb";
                    }
                }
            }
        }

Answers (4)