realbasic-nug.de
[Top] [All Lists]

Re: zu langsamer Code

To: realbasic-nug dot de at lists dot realsoftware dot com (REALbasic NUG German)
Subject: Re: zu langsamer Code
From: support at monkeybreadsoftware dot de (Christian Schmitz)
Date: Wed, 19 Oct 2005 22:15:45 +0200
Comments: Written on a PowerMac G4 and sent via DSL.
Delivered-to: realbasic-nug dot de at lists dot realsoftware dot com
<michaelkoop at t-online dot de> wrote:

> dim n as integer
> dim t as string
> 
> n=ListBox1.ListCount-1
> for i=0 to n
>     if ListBox1.Selected(i)=true then
>        t=t+trim(ListBox1.Cell(i,SpalteINr))+","
>     end if
> next
> EditField2.Text=t

und jetzt machen wir das noch schneller:

  dim n as integer
  dim a(-1) as string
  
  n=ListBox1.ListCount-1
  for i=0 to n
    if ListBox1.Selected(i) then
      a.Append trim(ListBox1.Cell(i,SpalteINr))
    end if
  next
  EditField2.Text=Join(a,",")
  
Wenn du willst kannst du auch noch ein "," dranhängen am Schluss.

if ListBox1.Selected(i)=true then 

ist übrigends ein =true mehr als nötig.

Und für die ganz schlauen noch eine Frage:

Warum ist

 t=t+(trim(ListBox1.Cell(i,SpalteINr))+",")

mindestens theoretisch schneller als das hier:

 t=t+trim(ListBox1.Cell(i,SpalteINr))+"," 

Mfg
Christian

-- 
Around ten thousand functions in one REALbasic plug-in. The MBS Plugin.
<http://www.monkeybreadsoftware.de/realbasic/plugins.shtml>

<Prev in Thread] Current Thread [Next in Thread>