delphi用例在AdvBadgeGlowButton1标题上

问题描述 投票:0回答:1

如何根据徽章标题使用案例陈述?试过:

procedure TForm2.Button1Click(Sender: TObject);
begin
case AdvBadgeGlowButton1.Caption of
'Test' :     showmessage('Test')
end;
''     :     showmessage('Empty')
end;

但我得到:

[dcc32错误] Unit2.pas(29):E2001所需的序数类型[dcc32错误]

Unit2.pas(30):E2010不兼容的类型:'整数'和'字符串'

delphi tms
1个回答
0
投票

case不能用于非ordinal types的值(通常是整数值),如错误消息所示。你需要使用if..else代替。

procedure TForm2.Button1Click(Sender: TObject);
begin
  if AdvBadgeGlowButton1.Caption = 'Test' then
    ShowMessage('Test')
  else if AdvBadgeGlowButton1.Caption = '' then
    ShowMessage('Empty')
  else
    ShowMessage('Got unknown caption ' + AdvBadgeGlowButton1.Caption);
end;
© www.soinside.com 2019 - 2024. All rights reserved.