Faster way of making long string?



I want to make a string of numbers from an integer list.
The code I'm using is pretty simple solution.

var
i: integer;
lstNumbers: TIntegerList;
strOut: string;
begin
strOut := '';
if lstNumbers.Count > 0 then
begin
strOut := IntToStr(lstNumbers[0]);
for i := 1 to lstNumbers.Count - 1 do
strOut := strOut + ', ' + IntToStr(lstNumbers[i]);
end;
end;

But I'm wondering whether this is an inefficient use of strOut.
It seems to me the program has to keep creating new instances of strOut,
then copy contents of previous instance into it (plus the new number of
course).

Would using "SetLength" to increase the size of the string as required make
a more efficient solution?
If so, could someone please give me an example how this could be done?

Thanks,
Ian.


.



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)