如何取字符串中的其中几位? 如何取字符串中的其中几位?如: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中的函数 怎么把已经打包好的软件逆反回来啊 如何让一个listbox中的某一数据通过一个BUTTON按钮转移到另一个listbox中去。 何以被禁用的按钮也能相应鼠标时间?大家都来看看,我在线等待 关于连接的问题 TChart 怎么预览呀?马上结帖 求一个应用问题的算法 怎样取得默认参数的值,有谁知道? 怎样改变inputQuery的字体? 我们公司要开发一套系统,同时实现c/s,b/s,支持各地分公司的使用,现在没决定用vb还是delphi,请大家发表意见! 网页中如何调用客户端 office? 这样一段程序在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;