procedure TForm1.biaodianfuhao(Str: string);
type
ACharSet=Set of char;
var
ii,Len :integer;
aaa:String;
begin
Len :=Length(Str);
for ii:= 1 to Len do
begin
aaa:=str[ii];
if aaa in ACharSet then
memo1.lines.add(aaa);
end;
end;
这段代码为什么不行?运行是抱一下错误!
[Error] Unit1.pas(212): '(' expected but 'THEN' found
[Error] Unit1.pas(213): Incompatible types: 'String' and 'Char'
[Error] Unit1.pas(226): Statement expected but end of file found
[Fatal Error] Project1.dpr(5): Could not compile used unit 'Unit1.pas'
请问如何解决这个问题?
代码提示,谢谢!
type
ACharSet=Set of char;
var
ii,Len :integer;
aaa:String;
begin
Len :=Length(Str);
for ii:= 1 to Len do
begin
aaa:=str[ii];
if aaa in ACharSet then
memo1.lines.add(aaa);
end;
end;
这段代码为什么不行?运行是抱一下错误!
[Error] Unit1.pas(212): '(' expected but 'THEN' found
[Error] Unit1.pas(213): Incompatible types: 'String' and 'Char'
[Error] Unit1.pas(226): Statement expected but end of file found
[Fatal Error] Project1.dpr(5): Could not compile used unit 'Unit1.pas'
请问如何解决这个问题?
代码提示,谢谢!
改为 aaa:Char
毕竟你ACharSet类型是字符集,而不是字符串集
宠辱不惊,看庭前花开花落,去留无意;毁誉由人,望天上云卷云舒,聚散任风。
————————————————————————————————————
type
ACharSet = Set of char;
var
ii,Len :integer;
aaa :char;
c : ACharSet;
begin
Len := Length(Str);
for ii:= 1 to Len do
begin
aaa:=str[ii];
if aaa in c then
memo1.lines.add(aaa);
end;end;集合是一个类型,你要定义它的对象
那个Char中包含有哪些东东?