delphi use case on AdvBadgeGlowButton1 caption

不羁岁月 提交于 2019-12-11 15:02:53

问题


How can you use a case statement depending on the badge caption ? Tried :

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

but am getting :

[dcc32 Error] Unit2.pas(29): E2001 Ordinal type required [dcc32 Error]

Unit2.pas(30): E2010 Incompatible types: 'Integer' and 'string'


回答1:


case cannot be used for values that are not ordinal types (typically integer values), as the error message says. You'll need to use if..else instead.

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;


来源:https://stackoverflow.com/questions/54402040/delphi-use-case-on-advbadgeglowbutton1-caption

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!