mardi 19 décembre 2017

Use an alternative of "if" statement for checkBoxes

I try to replace each "if" by a "for" or "while":

if (CheckObject1.Checked)
    XRPC.SetMemory(8184, value);
if (CheckObject2.Checked)
    XRPC.SetMemory(7848, value);
[...]
if (CheckObject20.Checked)
    XRPC.SetMemory(1800, value);

I already tried this but the problem is that I don't know how to increment the number at the end of checkBox:

int current = 8184;
int X = 1;
while (current > 1800)
{
    if (CheckObjectX.Checked) // regex?
        XRPC.SetMemory(current, value);
    X += 1;
    current -= 336;
}

I don't know if a regular expression can be used for "checkBox"... Any idea?




Aucun commentaire:

Enregistrer un commentaire