0

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

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 不兼容的类型:“整数”和“字符串”

4

1 回答 1

0

case如错误消息所述,不能用于非序数类型的值(通常是整数值)。您需要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;
于 2019-01-28T13:35:37.750 回答