delphi 为什么会出现这种问题,不懂,求解~~~~~
它提示错误是Build
Unit1.pas(39): Operator not applicable to this operand type
Unit1.pas(41): Operator not applicable to this operand type
Unit1.pas(43): Operator not applicable to this operand type
Unit1.pas(45): Operator not applicable to this operand type
Unit1.pas(47): ':=' expected but '=' found
Unit1.pas(47): Operator not applicable to this operand type
Unit1.pas(50): Declaration expected but 'IF' found
Unit1.pas(53): Illegal character in input file: ';' ($A3BB)
Unit1.pas(54): '.' expected but ';' found
Project1.dpr(5): Could not compile used unit 'Unit1.pas'
字符串应该可以通过数组的方式对单个字符进行索引的,为什么不能进行判断呢????
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
edt1: TEdit;
btn1: TButton;
procedure btn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
var
{$R *.dfm}
procedure TForm1.btn1Click(Sender: TObject);
var
char1 : set of Char;
Str:string;
i:Integer;
begin
char1:=[];
Str:=edt1.Text;
for i:=0 to Length(Str)-1 do
begin
if Str = 'a' or Str = 'A' then
char1:=char1+['a']
else if Str='e' or Str='E' then
char1:=char1+['e']
else if Str='i' or Str='I' then
char1:=char1+['e']
else if Str='o' or Str='O' then
char1:=char1+['e']
elseStr='u' or Str='U' then
char1:=char1+['e'];
end;
if char1 <> [] then
ShowMessage('含有元音字母')
else
ShowMessage('不含有元音字母');
end;
end.
啊,我明白了,是因为没加括号……幸亏没人看过:L 格式天下 发表于 2012-7-29 17:06 static/image/common/back.gif
啊,我明白了,是因为没加括号……幸亏没人看过
呵呵,粗心了吧~ 甲鱼你好
甲鱼再见
{:5_109:} :lol:lol:lol:lol...正准备学
页:
[1]