小弟是正在学delphi的,遇到点问题,希望有人能帮帮我源码:
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
Edit1: TEdit;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;
T_COLOR: string;
implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
begin
T_COLOR:=edit1.Text;
case T_COLOR of
'red':
begin
form1.color:=clred;
end;
'green':
begin
form1.color:=clgreen;
end;
else
form1.color:=clsilver;
end;
end;end.报错:
[Error] Unit1.pas(30): Ordinal type required
[Error] Unit1.pas(31): Incompatible types: 'Integer' and 'String'
[Error] Unit1.pas(35): Incompatible types: 'Integer' and 'String'
[Fatal Error] Project1.dpr(5): Could not compile used unit 'Unit1.pas'请问到底是什么错误呢
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
Edit1: TEdit;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;
T_COLOR: string;
implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
begin
T_COLOR:=edit1.Text;
case T_COLOR of
'red':
begin
form1.color:=clred;
end;
'green':
begin
form1.color:=clgreen;
end;
else
form1.color:=clsilver;
end;
end;end.报错:
[Error] Unit1.pas(30): Ordinal type required
[Error] Unit1.pas(31): Incompatible types: 'Integer' and 'String'
[Error] Unit1.pas(35): Incompatible types: 'Integer' and 'String'
[Fatal Error] Project1.dpr(5): Could not compile used unit 'Unit1.pas'请问到底是什么错误呢
'red':
begin
form1.color:=clred;‘red’应该是integer型,不能是string;
如:
case TCORLR OF
0:begin
end;
1:..
2:...
end;