其实使用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;end;

解决方案 »

  1.   

    同意楼上的
    TStringlist是很好的操纵txt文件的对象
      

  2.   

    对不起,如果格式固定,我想我理解错一点,你一共有三列,第一列返回时间
    第二列,三列返回实型数是吗?
    可以再写个函数,以空格为分界符,将一行的文本写入到一个数组里
    再根据column值取出,做适当的数据类型转换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;