vendredi 30 avril 2021

Trying to add the values of 4 check boxes together

this is probably very very simple but if someone could steer me int he right direction I would appreciate it.

Im trying to make a check list where the values of each box checked are all added together and displayed in a textbox with the code " weekExtras.Text = Convert.ToString(calWeekExtras()); " where the checkbox values are exAc = 1, exPt = 20, exDi = 20 and exVi = 2

(This is what I have so far)

 *public double calWeekExtras()
    {
        double exAc= 00.00;
        double exPt = 00.00;
        double exDi = 00.00;
        double exVi = 00.00;
        double total = 00.00;
        if (access.Checked)
        {
            exAc = 1.00;
        }
        else if (personalT.Checked)
        {
            exPt = 20.00;
        }
        else if (diet.Checked)
        
            exDi = 20.00;
        }
        else (accessVid.Checked)
        {
            exVi = 2.00;
        }
        total += exAc + exPt + exDi + exVi;
        return total;*

I think the 'total += exAc + exPt + exDi + exVi;' is wrong but I'm having trouble finding the answer.




Aucun commentaire:

Enregistrer un commentaire