当前位置:编程学习 > Delphi >>

delphi 这段源码谢谢纠正!!!

procedure TForm1.Button1Click(Sender: TObject);
begin
case label1.Caption of
*:=showmessage ('Label1.Caption 是“*”');
end;
end;
追问:

怎么才能用 case 来判断label.caption是什么!

答案:

string类型的是不以用case,要用IF来判断

procedure TForm1.Button1Click(Sender: TObject);
begin
if label1.Caption = '*' then
 showmessage ('Label1.Caption 是“*”');

end;

case不能处理string类型,但可以处理char类型。如你的代码可以如下:procedure TForm1.Button1Click(Sender: TObject);
begin
case label1.Caption[1] of
'*':=showmessage ('Label1.Caption 是“*”');
end;
end;

上一个:字符串转二进制怎么转? delphi
下一个:Delphi7中ADODataSet如何使用?

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,