function Pos(Substr: string; S: string): Integer;DescriptionPos searches for a substring, Substr, in a string, S. Substr and S are string-type expressions.Pos searches for Substr within S and returns an integer value that is the index of the first character of Substr within S. Pos is case-sensitive. If Substr is not found, Pos returns zero.以上是POS函数的定义:在tmpStr这个字符串中寻找resStr的位置然后返回,用对话框显示出来
//運行一個例子,看看就知道了 //有些東西自己可以試試 var resStr,tmpStr: string; begin resStr := 'China'; tmpStr := 'HAHA China For TO GO!'; showmessage(IntToStr(pos(resStr,tmpStr))); //6 resStr := 'USA'; showmessage(IntToStr(pos(resStr,tmpStr))); //0 end;
IntToStr():数值变量转换成字符变量
我是初学者,请大家耐心解释,谢谢!
Pos(s1,s2):s1在s2中的位置
Inttostr整数转为字符串
Showmessage显示消息
//有些東西自己可以試試
var
resStr,tmpStr: string;
begin
resStr := 'China';
tmpStr := 'HAHA China For TO GO!';
showmessage(IntToStr(pos(resStr,tmpStr))); //6
resStr := 'USA';
showmessage(IntToStr(pos(resStr,tmpStr))); //0
end;