如何取字符串中的其中几位? 如何取字符串中的其中几位?如:sum=main_Form.ADOQuery3.FieldByName("stock_id").AsString.SubString(7,6);但是这样不行?请问是哪里错了? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 用copy函数copy('delphi is good!',1,6) {================================================================= 功 能: 功 能: 返回开始和截止字符之间的字符串,保存在TStringList中 参 数: BeginStr :开始字符 EndStr :截止字符 SourceStr :原字符串 RectList :返回的字符串列表 返回值: Integer :开始字符在原字符串中出现的个数 备 注: 查找字符串 版 本: 1.0 2006/09/14 09:55:00=================================================================}Function GetStr(BeginStr,EndStr:String;SourceStr:WideString;RectList:TStringList):integer;var ll_pos1,ll_pos2,ll_pos3,ll_pos4:Integer; ll_count,i,ll_count1:Integer; ls_tempstr,ls_str:String;begin ls_tempstr:= SourceStr; ll_count := StrNum(BeginStr,ls_tempstr); ll_pos1 := pos(BeginStr,ls_tempstr); ll_pos3 := 0; ll_pos4 := 0; for i:=1 to ll_count do begin ll_pos1 := Pos(BeginStr,ls_tempstr); ll_pos2 := Pos(EndStr ,ls_tempstr); ls_str := Copy(ls_tempstr,ll_pos1 + Length(BeginStr),ll_pos2 - ll_pos1 - Length(BeginStr)); RectList.Add(ls_str); ls_tempstr := StringReplace(ls_tempstr,BeginStr,' #'+IntToStr(i)+'# ',[rfIgnoreCase]); ls_tempstr := StringReplace(ls_tempstr,EndStr ,' @'+IntToStr(i)+'@ ',[rfIgnoreCase]); end; Result := ll_count;end; copy(str,1,6) 取str 第一位后的6位(包括第一位) copy没错,SubString是C++Builder中的函数 cxgrid 分组分页打印 关于服务程序的使用 关于TDBGrid的问题 关于TRY语句的问题 如何移动TListView中的一个或多个Item? 本人刚刚开始学习delphi,能否推荐几本入门的书籍啊〉? 有办法让 delphi 编的cgi(*.exe)程序做到弹出信息窗的效果吗? delphi6.0的数据库登录问题? ehlib安装问题 请教在在DLL中加入ADO为什么会报'尚未调用coInitiailize’(使用的是Delphi5) 这样一段程序在DELPHI里该怎么运行。 delphi TStringGrid 合并单元格
copy('delphi is good!',1,6)
功 能: 功 能: 返回开始和截止字符之间的字符串,保存在TStringList中
参 数: BeginStr :开始字符
EndStr :截止字符
SourceStr :原字符串
RectList :返回的字符串列表
返回值: Integer :开始字符在原字符串中出现的个数
备 注: 查找字符串
版 本:
1.0 2006/09/14 09:55:00
=================================================================}
Function GetStr(BeginStr,EndStr:String;SourceStr:WideString;RectList:TStringList):integer;
var ll_pos1,ll_pos2,ll_pos3,ll_pos4:Integer;
ll_count,i,ll_count1:Integer;
ls_tempstr,ls_str:String;
begin
ls_tempstr:= SourceStr; ll_count := StrNum(BeginStr,ls_tempstr);
ll_pos1 := pos(BeginStr,ls_tempstr);
ll_pos3 := 0;
ll_pos4 := 0;
for i:=1 to ll_count do
begin
ll_pos1 := Pos(BeginStr,ls_tempstr);
ll_pos2 := Pos(EndStr ,ls_tempstr);
ls_str := Copy(ls_tempstr,ll_pos1 + Length(BeginStr),ll_pos2 - ll_pos1 - Length(BeginStr));
RectList.Add(ls_str);
ls_tempstr := StringReplace(ls_tempstr,BeginStr,' #'+IntToStr(i)+'# ',[rfIgnoreCase]);
ls_tempstr := StringReplace(ls_tempstr,EndStr ,' @'+IntToStr(i)+'@ ',[rfIgnoreCase]);
end;
Result := ll_count;
end;