风之谷
点亮心灵,基础补习中...

导航

<2012年5月>
293012345
6789101112
13141516171819
20212223242526
272829303112
3456789

统计
  • 随笔 - 15
  • 文章 - 1
  • 评论 - 35
  • 跟踪 - 0

公告
  • 有事点这里

文章分类

档案

随笔分类

相册

好友博客

技术站点

登录
    帐号
    密码
    记住我:
     
 

function StringIndex(const SearchString: string; StrList: array of string): Integer;
var
  I: Integer;
begin
  Result:= -1;
  for I:= 0 to High(StrList) do
    if CompareText(SearchString, StrList[I]) = 0 then
    begin
      Result:= I;
      Break;
    end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  case StringIndex('A', ['A', 'B', 'C']) of
   -1: ShowMessage('Not in the list');
    0: ShowMessage('A');
    1: ShowMessage('B');
    2: ShowMessage('C');
  end;
end;

From www.delphi3000.com

2004年10月31日 20:39
评论
  • # 回复: Using Case Structure With Strings
    reallike
    2004-11-1 15:16
    在StrUtils有一个IndexStr,一个IndexText。
主题  
姓名  
主页
验证码  
内容   
 

请不要发表可能给我们带来伤害的政治言论,谢谢配合