问题来源: http://www.cnblogs.com/del/archive/2007/12/18/1005161.html#1786227
{ 函数 } function ToAlignString(const str: string; len: Integer): string; var i,n: Integer; s: string; begin if Abs(len) < Length(str) then Result := str; n := (Abs(len) - Length(str)) * SizeOf(Char); for i := 1 to Length(str) do if Ord(str[i]) < 256 then Inc(n); if n > 0 then s := StringOfChar(' ', n); if Len > 0 then Result := s + str else Result := str + s; end; { 测试 } procedure TForm1.FormCreate(Sender: TObject); var s1,s2: string; begin Memo1.Font.Name := '宋体'; Memo1.Font.Size := 9; Memo1.Clear; s1 := '中国abc'; s2 := '中国人民abc'; Memo1.Lines.Add(ToAlignString(s1, -10)); Memo1.Lines.Add(ToAlignString(s2, -10)); Memo1.Lines.Add(ToAlignString(s1, 10)); Memo1.Lines.Add(ToAlignString(s2, 10)); end;