Can the following if statement be converted to a case statement?
if (Number >= 5) and (Number <= 10) then
lblAnswer.Caption := 'in range'
else
lblAnswer.Caption := 'out of range';
My Answer :
Yes it can
case (number >= 5) and (Number <= 10) of
lblAnswer.Caption := 'in range';
lblAnswer.Caption := 'out of range';
end;
Is this correct?
If Number has some integer data type, then:
case number of
5 .. 10: lblAnswer.Caption := 'in range';
else lblAnswer.Caption := 'out of range';
end;