Re: Faster way of making long string?



Hello Ian,

Ian Hinson wrote:
> I want to make a string of numbers from an integer list.

how do You like this?

var
  i: integer;
  lstNumbers: TIntegerList;
  strOut: string;
  sl : TStringList;
begin
  strOut := '';
  sl := TStringList.Create;
  try
    for i := 0 to lstNumbers.Count-1 do
      sl.Add(IntToStr(lstNumbers[i]);
    strOut := sl.CommaText;
  finally
    sl.Free;
  end;
end;

All NumberStrings are placed in List, strOut is composed from the list strings, list is freed after usage. Should be faster.
SetLength would be nice, but than You have to call IntToStr twice for each entry, first to get the length, second to get the string.


Thanks,
Ian.

Best regards Ekkehard Domning .



Relevant Pages

  • Re: Removing Formatting Symbols from Phone numbers
    ... Const strNumbers As String = "0123456789" ... Dim strOut As Variant ... For intCount = 1 To Len ...
    (microsoft.public.access.queries)
  • Re: parse field
    ... Public Function StartPart(strIn As String) As Long ... Dim strOut As String ... Dim strChr As String ...
    (microsoft.public.access.gettingstarted)
  • RE: parse field
    ... Public Function StartPart(strIn As String) As Long ... Dim strOut As String ... Dim strChr As String ...
    (microsoft.public.access.gettingstarted)
  • Re: How do you remove all the symbols?
    ... I think Chr correctly places those char's into a test string. ... Dim bArr1() As Byte, bArr2As Byte ... Dim strIn$, strOut1$, strOut2$, sCorrect$ ... Dim strIn As String, strOut As String, s As String ...
    (microsoft.public.excel.programming)
  • Re: How do I delete characters using a query?
    ... You could use a custom VBA function to do this. ... Public Function fStripToSpecifiedOnlyAs String ... Dim strOut As String ... For intCount = 1 To Len ...
    (microsoft.public.access.queries)