delphi 这段源码谢谢纠正!!!
procedure TForm1.Button1Click(Sender: TObject);begin
case label1.Caption of
*:=showmessage ('Label1.Caption 是“*”');
end;
end;
追问:怎么才能用 case 来判断label.caption是什么!
追问:怎么才能用 case 来判断label.caption是什么!
答案:string类型的是不以用case,要用IF来判断
procedure TForm1.Button1Click(Sender: TObject);
case不能处理string类型,但可以处理char类型。如你的代码可以如下:procedure TForm1.Button1Click(Sender: TObject);
begin
if label1.Caption = '*' then
showmessage ('Label1.Caption 是“*”');
end;
begin
case label1.Caption[1] of
'*':=showmessage ('Label1.Caption 是“*”');
end;
end;