delphi 下列语句如果用case语句来写,该如何写?

来源:百度知道 编辑:UC知道 时间:2024/06/27 19:48:04
if Avoltage>MaxVol then MaxVol:=Avoltage;
if Bvoltage>MaxVol then MaxVol:=Bvoltage;
if Cvoltage>MaxVol then MaxVol:=Cvoltage;

if MaxVol=Avoltage then
begin
voltagedata[0]:=ceil(voltage[0]/10000.0*220.0*1000/60);
voltagedata[1]:=ceil(voltage[1]/10000.0*220.0*1000/60);
end
else if MaxVol=Bvoltage then
begin
voltagedata[0]:=ceil(voltage[2]/10000.0*220.0*1000/60);
voltagedata[1]:=ceil(voltage[3]/10000.0*220.0*1000/60);
end
else if MaxVol=Cvoltage then
begin
voltagedata[0]:=ceil(voltage[4]/10000.0*220.0*1000/60);
voltagedata[1]:=ceil(voltage[5]/10000.0*220.0*1000/60);
end;

if MaxVol=null then
begin
voltagedata[0]:=$00;
voltagedata[1]:=$00;
end
else if MaxVol<10 then
begin
voltagedata[0]:=$00;

case语句中的条件应该是可以穷尽的.

比如:
case MaxVol of
0:begin
end;
1:begin
end;
....
12:begin
end;
13,14:begin
end;
else
begin
//如果MaxVol的值不在0..14的范围内
//就执行这里的语句.
end;
end;//case语句结束了.
MaxVol到100以上都可以,但要记住,它必须是整数值,否则搞不成的.