我是想进行字符串匹配啊,这几行代码如下这的编译通不过, 为什么 strName ='lib'; case strName of
case 'lib' : Result := 'lib';
else
Result := 'sss';
end;
case 'lib' : Result := 'lib';
else
Result := 'sss';
end;
解决方案 »
- delphi 7 怎样制作一步步提示的界面
- 把窗口缩小到屏幕右下角的通知区域,不在任务栏中显示,该怎么实现呢?
- 如何用sql语句,而不是用数据集更新备注型字段?
- 怎样知道另外的程序中的一个Window创建并显示了出来
- 关于DBGRIDEH点击标题进行打印的问题?
- XSL格式问题--插入空字符
- 如何创建动态打印啊!!(急)
- 怎么把wideString变成String
- 看过我贴子(http://www.csdn.net/expert/topic/958/958167.xml?temp=.1907923)的朋友来这里领分(2),实现我的承诺,每人20
- 串口通讯:接收不到完整的数据?
- ACSII 码的问题,
- 有人要招聘delphi程序员吗?请进来一看啊!
strName ='lib'; case strName of
'lib' : Result := 'lib';
else
Result := 'sss';
end;
你可以把它转化为整型,如:
if strName ='lib' then i:=0;
.
.
case i of
0 : Result := 'lib';
else
Result := 'sss';
end;
Result := 'lib'
else
Result := 'sss';
if strName ='lib' then Result:='lib';
...不就完了么?
caseList1: statement1;
...
caseListn: statementn;
endwhere selectorExpression is any expression of an ordinal type (string types are invalid) and each caseList is one of the following:A numeral, declared constant, or other expression that the compiler can evaluate without executing your program. It must be of an ordinal type compatible with selectorExpression. Thus 7, True, 4 + 5 * 3, 'A', and Integer('A') can all be used as caseLists, but variables and most function calls cannot. (A few built-in functions like Hi and Lo can occur in a caseList. See Constant expressions.)
A subrange having the form First..Last, where First and Last both satisfy the criterion above and First
is less than or equal to Last.A list having the form item1, ..., itemn, where each item satisfies one of the criteria above.看清楚了
where selectorExpression is any expression of an ordinal type (string types are invalid) and each caseList is one of the following:
其中(string types are invalid)
然后用i:=TSTRINGLISTOBJECT.indexof(yourcasestring)
然后
case i of
0 : Result := 'lib';
else
Result := 'sss';
end;