function splitstr(str:string;column:integer):string;
var
Nowstr:string;
tempstr:string;
temparray:array of string;
iCount:integer;
NowPos:integer;
begin
iCount:=0;
NowStr:=trim(str);
NowPos:=Pos(' ',Nowstr);
while Nowpos<>0 do
begin
inc(iCount);
setlength(temparray,iCount);
tempArray[iCount-1]:=copy(Nowstr,1,NowPos-1);
NowStr:=copy(NowStr,nowpos+1,length(Nowstr)-nowpos);
NowPos:=pos(' ',Nowstr);
end;
inc(iCount);
setlength(temparray,icount);
temparray[Icount-1]:=NowStr;
result:=temparray[column-1];
end;
其实使用TstringList可以很容易实现你的要求。而且仅仅是一个函数就可以了。我直接在这里输入的代码,所以可能有语法错,请注意检查一下,不好意思。另外,你使用strtoint只能返回整型数,不能返回浮点数
function GetValue(textfile:Tfilename;row,column:integer):float;
var
MystringList:TStringList;
str1,str2:string;
begin
try
MyStringList;=TStringList.create;
MyStringList.loadfromfile(textFile);
str1:=MystringList[row-1];
str2:=copy(str1,5,6)//这里根据你的文本格式自定
result:=strtofloat(str2);
finally
MyStringList.free;