unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls,
Forms,
Dialogs, StdCtrls, Buttons;

type
TForm1 = class(TForm)
Label1: TLabel;
Edit1: TEdit;
Label2: TLabel;
StaticText1: TStaticText;
Label3: TLabel;
StaticText2: TStaticText;
BitBtn1: TBitBtn;
procedure BitBtn1Click(

Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.BitBtn1Click(Sender: TObject);
var
totalcompra : integer;
valordesc, totalpagar : real;
begin
totalcompra := strtoint(Edit1.Text);
case totalcompra of
0..100 : valordesc := 0.10;
101..250 : valordesc := 0.20;
251..300: valordesc := 0.30;
else valordesc := 0.40;
end;
StaticText1.Caption := formatfloat('R$ 0.00',valordesc);
totalpagar := totalcompra * valordesc;
StaticText2.Caption := formatfloat('R$ 0.00',totalpagar);

end;

end.



marcio escreveu:
>
> Boa tarde galera :)
>
> estou com um pro aki com uso de case, o problema é este, contruir um
> sistema para uma empresa resolve realizar uma promoção com descontos
> entre 10 e 40 por cento de acordo com o total a ser pago pelo cliente
> fiz o exercicio contudo está gerando o seguinte erro:
>
> [Error] Unit1.pas(37): Ordinal type required
>
> o cod da minha unit:
> unit Unit1;
>
> interface
>
> uses
> Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls,
> Forms,
> Dialogs, StdCtrls, Buttons;
>
> type
> TForm1 = class(TForm)
> Label1: TLabel;
> Edit1: TEdit;
> Label2: TLabel;
> StaticText1: TStaticText;
> Label3: TLabel;
> StaticText2: TStaticText;
> BitBtn1: TBitBtn;
> procedure BitBtn1Click(Sender: TObject);
> private
> { Private declarations }
> public
> { Public declarations }
> end;
>
> var
> Form1: TForm1;
>
> implementation
>
> {$R *.dfm}
>
> procedure TForm1.BitBtn1Click(Sender: TObject);
> var
> totalcompra, valordesc, totalpagar : real;
> begin
> totalcompra := strtoint(Edit1.Text);
> case totalcompra of
> 0..100 : valordesc := 0.10;
> 101..250 : valordesc := 0.20;
> 251..300: valordesc := 0.30;
> else valordesc := 0.40;
> end;
> StaticText1.Caption := formatfloat('R$ 0.00',valordesc);
> totalpagar := totalcompra * valordesc;
> StaticText2.Caption := formatfloat('R$ 0.00',totalpagar);
>
> end;
>
> end.
>
> Como posso resolver isso ?????
>
>  

Responder a