J
John Dann
Is it reasonable practice to use a control to hold a variable value?
There's a (Boolean) flag that I want to allow the user to set or not
as they wish. This will be set either simply by a checkbox on the main
form of by a pair of radio buttons within a small groupbox. (These two
approaches are AFAICS equivalent but I prefer the radio buttons
because they show explicitly which of the two options has been
chosen.)
I was then going to declare a Boolean variable and set this according
to the state of the checkbox or radio button controls, changing the
value in the various click events etc.
But maybe this use of a separate variable is totally superfluous. When
I get to the point in the code where I need to know whether the flag
is set or not I could just check directly the state of the checkbox or
one of the option buttons. Is there any good reason not to go with
this simpler approach?
JGD
There's a (Boolean) flag that I want to allow the user to set or not
as they wish. This will be set either simply by a checkbox on the main
form of by a pair of radio buttons within a small groupbox. (These two
approaches are AFAICS equivalent but I prefer the radio buttons
because they show explicitly which of the two options has been
chosen.)
I was then going to declare a Boolean variable and set this according
to the state of the checkbox or radio button controls, changing the
value in the various click events etc.
But maybe this use of a separate variable is totally superfluous. When
I get to the point in the code where I need to know whether the flag
is set or not I could just check directly the state of the checkbox or
one of the option buttons. Is there any good reason not to go with
this simpler approach?
JGD