Hi everyone!
I have a pretty simple problem, but I don't really know how to fix it.
I have a TRadioBox, and when I select an option, it increments the value of a variable by X depending on the item selected.
The problem is: if the user changes the chosen option, it increments the value of the var, but it doesn't deduct the previous added value. Is there a way of doing it automatically? If not, how can I fix it?
procedure TForm4.RadioGroup1SelectionChanged(Sender: TObject);
begin
if RadioGroup1.ItemIndex = 0 then
precioBase := precioBase + 20000 else
if RadioGroup1.ItemIndex = 1 then
precioBase := precioBase + 20000 else
if RadioGroup1.ItemIndex = 2 then
precioBase := precioBase + 10000 else
if RadioGroup1.ItemIndex = 3 then
precioBase := precioBase + 5000 else
if RadioGroup1.ItemIndex = 4 then
precioBase := precioBase + 5000;
costo.caption := FloatToStr(precioBase);
end;
Thanks!