小弟写一个delphi的程序,要用到pos,copy,delete等几个处理字符串的函数,但是好像有点问题:
1.程序运行到这句话,即if (Pos(substr,str)=0) then 时,提示出错invalid variant type conversion.
2.键入pos,然后用ctrl+space出现的提示窗口中出现的是procedure pos,而不是function pos(substr:string;s:string)integer。copy和delete也存在类似问题。希望各位高手不吝赐教,先谢谢了!

解决方案 »

  1.   

    没有问题啊,都是这样用的
    我的代码的一部分,没有问题啊,再看看是不是别的错误:
    if Pos('L|1|F',LStr1) = 0 then
        IsError := true
      else
      

  2.   

    是不是uses部分需要加上system呢,但是好像也不对
      

  3.   

    俺也试了,用ctrl+space出现的提示窗口中出现的也是procedure pos.
    但是,Pos(substr,str)没有问题。例↓function DelZero(S: String): String; //去除’0’
    begin
      while Pos('0', S) > 0 do Delete(S,Pos('0',S),1);
      Result := S;
    end;procedure TForm1.Button1Click(Sender: TObject);
    begin
      showMessage(DelZero('0003044'));
    end;
      

  4.   

    UnitSystemCategorystring handling routinesfunction Pos(Substr: string; S: string): Integer;