trim 函数 从给定的字符串中删除前导和尾部的空格及控制字符 
trimleft 函数 从给定的字符串中删除首部的空格及控制字符 
trimright 函数 从给定的字符串中删除尾部的空格及控制字符 

解决方案 »

  1.   

    function TForm1.StrConvert(ConvertStr:WideString):string;
    var
      MyVar:string;
      i:integer;
    begin
      showmessage(InttoStr(Length(ConvertStr)));
      for i:=0 to Length(ConvertStr) do begin
        if ConvertStr[i]<>' ' then begin
          showmessage(ConvertStr[i]);
          MyVar:=MyVar+ConvertStr[i];
        end;
      end;
    end;注意:string与widestring
      

  2.   

    你干脆用stringreplace吧
    function DeleteSpace(s:String):String;
    begin
      result:=stringreplace(s,' ','',[rfReplaceAll,rfIgnoreCase]);
    end;
      

  3.   

    同意楼上的。
    最简单就是用StringReplace取代所有的空格