关于Delphi中Case用法
procedureTForm9.Button1Click(Sender:TObject);VarA,B,C,D:Double;beginA:=StrToFloat(edi...
procedure TForm9.Button1Click(Sender: TObject);
Var
A,B,C,D: Double;
begin
A:=StrToFloat(edit1.text) ;
B:=StrToFloat(edit2.text) ;
if ComboBox1.itemindex=-1 then
label1.Caption:='估算价:';
case A of
0..1000000:
begin
C:=A*1.3/1000;
D:=C*B;
Edit3.Text:=FloatTostr(C);
Edit4.Text:=FloatTostr(D);
end;
1000001..5000000:
begin
C:=1000000*1.3/1000+(A-1000000)*1.1/1000;
D:=C*B;
Edit3.Text:=FloatTostr(C);
Edit4.Text:=FloatTostr(D);
end;
5000001..10000000:
begin
C:=1000000*1.3/1000+(4000000)*1.1/1000+(A-5000000)*0.9/1000;
D:=C*B;
Edit3.Text:=FloatTostr(C);
Edit4.Text:=FloatTostr(D);
end;
10000001..50000000:
begin
C:=1000000*1.3/1000+(4000000)*1.1/1000+(5000000)*0.9/1000+(A-10000000)*0.7/1000;
D:=C*B;
Edit3.Text:=FloatTostr(C);
Edit4.Text:=FloatTostr(D);
end;
50000001..100000000:
procedure TForm9.Button1Click(Sender: TObject);
Var
A,B,C,D: Double;
begin
A:=StrToFloat(edit1.text) ;
B:=StrToFloat(edit2.text) ;
if ComboBox1.itemindex=-1 then
label1.Caption:='估算价:';
case A of
0..1000000:
begin
C:=A*1.3/1000;
D:=C*B;
Edit3.Text:=FloatTostr(C);
Edit4.Text:=FloatTostr(D);
end;
1000001..5000000:
begin
C:=1000000*1.3/1000+(A-1000000)*1.1/1000;
D:=C*B;
Edit3.Text:=FloatTostr(C);
Edit4.Text:=FloatTostr(D);
end;
5000001..10000000:
begin
C:=1000000*1.3/1000+(4000000)*1.1/1000+(A-5000000)*0.9/1000;
D:=C*B;
Edit3.Text:=FloatTostr(C);
Edit4.Text:=FloatTostr(D);
end;
10000001..50000000:
begin
C:=1000000*1.3/1000+(4000000)*1.1/1000+(5000000)*0.9/1000+(A-10000000)*0.7/1000;
D:=C*B;
Edit3.Text:=FloatTostr(C);
Edit4.Text:=FloatTostr(D);
end;
50000001..100000000:
begin
C:=1000000*1.3/1000+(4000000)*1.1/1000+(5000000)*0.9/1000+(40000000)*0.7/1000+(A-10000000)*0.5/1000;
D:=C*B;
Edit3.Text:=FloatTostr(C);
Edit4.Text:=FloatTostr(D);
end;
else
begin
C:=1000000*1.3/1000+(4000000)*1.1/1000+(5000000)*0.9/1000+(40000000)*0.7/1000+(50000000)*0.5/1000+(A-100000000)*0.4/1000;
D:=C*B;
Edit3.Text:=FloatTostr(C);
Edit4.Text:=FloatTostr(D);
end;
end;
End ;
错误提示:[dcc32 Error] Unit9.pas(54): E2001 Ordinal type required
[dcc32 Fatal Error] Project9.dpr(5): F2063 Could not compile used unit 'Unit9.pas'
Failed
怎么解决? 展开
Var
A,B,C,D: Double;
begin
A:=StrToFloat(edit1.text) ;
B:=StrToFloat(edit2.text) ;
if ComboBox1.itemindex=-1 then
label1.Caption:='估算价:';
case A of
0..1000000:
begin
C:=A*1.3/1000;
D:=C*B;
Edit3.Text:=FloatTostr(C);
Edit4.Text:=FloatTostr(D);
end;
1000001..5000000:
begin
C:=1000000*1.3/1000+(A-1000000)*1.1/1000;
D:=C*B;
Edit3.Text:=FloatTostr(C);
Edit4.Text:=FloatTostr(D);
end;
5000001..10000000:
begin
C:=1000000*1.3/1000+(4000000)*1.1/1000+(A-5000000)*0.9/1000;
D:=C*B;
Edit3.Text:=FloatTostr(C);
Edit4.Text:=FloatTostr(D);
end;
10000001..50000000:
begin
C:=1000000*1.3/1000+(4000000)*1.1/1000+(5000000)*0.9/1000+(A-10000000)*0.7/1000;
D:=C*B;
Edit3.Text:=FloatTostr(C);
Edit4.Text:=FloatTostr(D);
end;
50000001..100000000:
procedure TForm9.Button1Click(Sender: TObject);
Var
A,B,C,D: Double;
begin
A:=StrToFloat(edit1.text) ;
B:=StrToFloat(edit2.text) ;
if ComboBox1.itemindex=-1 then
label1.Caption:='估算价:';
case A of
0..1000000:
begin
C:=A*1.3/1000;
D:=C*B;
Edit3.Text:=FloatTostr(C);
Edit4.Text:=FloatTostr(D);
end;
1000001..5000000:
begin
C:=1000000*1.3/1000+(A-1000000)*1.1/1000;
D:=C*B;
Edit3.Text:=FloatTostr(C);
Edit4.Text:=FloatTostr(D);
end;
5000001..10000000:
begin
C:=1000000*1.3/1000+(4000000)*1.1/1000+(A-5000000)*0.9/1000;
D:=C*B;
Edit3.Text:=FloatTostr(C);
Edit4.Text:=FloatTostr(D);
end;
10000001..50000000:
begin
C:=1000000*1.3/1000+(4000000)*1.1/1000+(5000000)*0.9/1000+(A-10000000)*0.7/1000;
D:=C*B;
Edit3.Text:=FloatTostr(C);
Edit4.Text:=FloatTostr(D);
end;
50000001..100000000:
begin
C:=1000000*1.3/1000+(4000000)*1.1/1000+(5000000)*0.9/1000+(40000000)*0.7/1000+(A-10000000)*0.5/1000;
D:=C*B;
Edit3.Text:=FloatTostr(C);
Edit4.Text:=FloatTostr(D);
end;
else
begin
C:=1000000*1.3/1000+(4000000)*1.1/1000+(5000000)*0.9/1000+(40000000)*0.7/1000+(50000000)*0.5/1000+(A-100000000)*0.4/1000;
D:=C*B;
Edit3.Text:=FloatTostr(C);
Edit4.Text:=FloatTostr(D);
end;
end;
End ;
错误提示:[dcc32 Error] Unit9.pas(54): E2001 Ordinal type required
[dcc32 Fatal Error] Project9.dpr(5): F2063 Could not compile used unit 'Unit9.pas'
Failed
怎么解决? 展开
1个回答
2017-03-05
展开全部
var
A: integer;
B, C, D: Double;
begin
A := StrToIntDef(edit1.text, 0);
B := StrToFloatDef(edit2.text, 0);
if ComboBox1.itemindex = -1 then
label1.Caption := '估算价:';
if A <= 0 then
begin
label1.Caption := 'A 输入错误';
edit1.Text := '';
edit1.SetFocus;
PlaySound(pchar('C:\Alert.wav'), 0, SND_ASYNC); //uses MMSystem;
exit;
end;
if B <= 0 then
begin
label1.Caption := 'B 输入错误';
edit2.Text := '';
edit2.SetFocus;
//Beep;
MessageBeep(MB_ICONEXCLAMATION);
exit;
end;
case A of
0..1000000:
C := A * 1.3 / 1000;
1000001..5000000:
C := 1000000 * 1.3 / 1000 + (A - 1000000) * 1.1 / 1000;
5000001..10000000:
C := 1000000 * 1.3 / 1000 + (4000000) * 1.1 / 1000 + (A - 5000000) * 0.9 / 1000;
10000001..50000000:
C := 1000000 * 1.3 / 1000 + (4000000) * 1.1 / 1000 + (5000000) * 0.9 / 1000 + (A - 10000000) * 0.7 / 1000;
50000001..100000000:
C := 1000000 * 1.3 / 1000 + (4000000) * 1.1 / 1000 + (5000000) * 0.9 / 1000 + (40000000) * 0.7 / 1000 + (A -
10000000) * 0.5 / 1000;
else
C := 1000000 * 1.3 / 1000 + (4000000) * 1.1 / 1000 + (5000000) * 0.9 / 1000 + (40000000) * 0.7 / 1000 +
(50000000) * 0.5 / 1000 + (A - 100000000) * 0.4 / 1000;
end;
D := C * B;
Edit3.Text := FloatTostr(C);
Edit4.Text := FloatTostr(D);
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询