how to show messageBox just once?
<p>newbie in learning c# here, im calculating cgpa and when user pick the number of subject they take, accordingly, the textBox will Enabled true according to the number of user subject and the rest is Enabled false. So when im clicking calculateCGPA, i want to popup message if the user input is empty but messageBox is shown x number of time according to the number that user left empty. How to get it to show only once. Tqvm in advanced. Explanation is very much appreciated.</p>

<p>1.CheckingUserCheckedRadioButton</p>

<pre><code>private void DisplayTextBox(Control con)
    {
        foreach (Control c in con.Controls)
        {
            if (rad1.Checked)
            {
                if (c is TextBox)
                {
                    ((TextBox)c).Enabled = false;
                    txtCCode1.Enabled = true;
                    txtGrade1.Enabled = true;
                }
                else
                {
                    DisplayTextBox(c);
                }

            }
       }
}
</code></pre>

<p>2.DisplayingMessageBoxWhenClickingCalculate</p>

<pre><code>private void calculate(Control con)
    {
        foreach (Control c in con.Controls)
        {
            if (c is TextBox)
            {
                if (c.Text == "")
                {
                    DialogResult x = new DialogResult();
                    x = MessageBox.Show("TextBox cannot be Empty");
                    if (x == DialogResult.OK)
                        txtCCode1.Focus();
                }
                else
                {
                    int totalCredHours = 0;
                    CalcTotalCredHours(credHour1, credHour2, credHour3, credHour4, credHour5, credHour6, ref totalCredHours);
                    courseGP1 = CalcCourseGradePoint(credHour1, gradePoint1);
                    courseGP2 = CalcCourseGradePoint(credHour2, gradePoint2);
                    courseGP3 = CalcCourseGradePoint(credHour3, gradePoint3);
                    courseGP4 = CalcCourseGradePoint(credHour4, gradePoint4);
                    courseGP5 = CalcCourseGradePoint(credHour5, gradePoint5);
                    courseGP6 = CalcCourseGradePoint(credHour6, gradePoint6);
                    double totalCGP = CalcTotalCGP(courseGP1, courseGP2, courseGP3, courseGP4, courseGP5, courseGP6);
                    double gpa = CalcGPA(totalCGP, totalCredHours);
                    lblGPA.Text = gpa.ToString("N");
                }
            }
            else
            {
                calculate(c);
            }
        }              
    }
</code></pre>