我正在尝试在Delphi 7中进行血压类别检查,而我刚认识Delphi已有几个星期了。问题是,每当我输入大于120的数字时,标签标题始终显示正常。这是我的代码:
procedure TForm1.Button1Click(Sender: TObject);
var a,b:real;
begin
a:=strtofloat(edit1.Text);
if (a<120) then label1.caption:='optimal'
else if (a>120) then label1.caption:='normal'
else if (a<130) then label1.caption:='normal'
else if (a>130) then label1.caption:='normal high'
else if (a<140) then label1.caption:='normal high'
else if (a>140) then label1.caption:='grade 1 hypertension'
else if (a<160) then label1.caption:='grade 1 hypertension'
else if (a>160) then label1.caption:='grade 2 hypertension'
else if (a<180) then label1.caption:='grade 2 hypertension'
else if (a>181) then label1.caption:='grade 3 hypertension'
end;
end.
Run Code Online (Sandbox Code Playgroud)
可能是一些常见的错误,但我仍然无法自己弄清楚,任何帮助都会有很大帮助,谢谢。