UnitSystemCategorystring handling routinesfunction 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.
解决方案 »
- 如何在循环中让窗口句柄响应消息
- 如何把ExcelApplication1 或是CreateOleObject( 'Excel.Application' ) 打开的EXCEL 放到我自已的窗体容器中。
- 请问一个关于释放内存的问题
- 有用过videoforwin视频控件(VFW)的吗?教教我怎么用。可者给出它的网站。
- 简单问题(在线待)
- 天津的朋友请进来,留联系方法好交流!
- 如何用for语句对日期型变量进行循环?
- 控件级小问题:关于dbedit和label
- 指针^
- 菜鸟的两个问题?
- 关于句柄的疑问???
- 请问,有哪位大哥知道学习Windows各项原理的资料?我记得是什么什么Library!可是想不起来了.
str:String;
PtPos,len,k:integer;
begin
PtPos:=Pos('.',Paytotal);
len:=length(Paytotal);
if PtPos<>0 then begin
if (PtPos-1)>5 then begin
showmessage('超出范围');
abort;
end;
for k:=1 to 5-(PtPos-1) do
str:=str+'0';
str:=str+StringReplace(Paytotal,'.','',[]);
for k:=1 to 4-(len-PtPos) do
str:=str+'0';
end
else begin
if len>5 then begin
showmessage('超出范围');
abort;
end;
for k:=1 to 5-len do
str:=str+'0';
str:=str+Paytotal+'0000';
end;
result:=str;
end;
var
intLocation : integer;
strLength : integer;
strMessages : string;
begin
Result := False;
if (trim(strFirst) = '') or (trim(strSecond) ='') then
begin
MessageBox(Handle, '对不起,要比较的字符不能为空。', '注意',
MB_OK + MB_ICONWARNING);
Exit;
end;
strMessages := '字符串“' + strFirst + '”中没有包含字符串“' +
strSecond + '”。';
intLocation := pos(strSecond, strFirst);
if intLocation > 0 then
begin
Result := True;
strLength := intLocation + Length(strSecond) - 1;
if Length(strSecond) <2 then
strMessages := '指定的字符串“' + strSecond +
'”存在于字符串“' + strFirst +
'”中。' + #13 + '“' + strFirst +
'”中的第 ' + inttostr(intLocation) +
' 个字符就是!'
else
strMessages := '字符串“' + strFirst +
'”中包含字符串“' + strSecond + '”。' +
'字符串“' + strFirst + '”中 ' +
inttostr(intLocation) + ' 至 ' +
inttostr(strLength) + ' 的字符串即是。';
end;
if ShowMsg then
MessageBox(Handle, Pchar(strMessages), '提示',
MB_OK + MB_ICONINFORMATION);
end;//调用例子:
TestTwoString('abcdefg','bcd',True);