Thema: Delphi Variablen sortieren

Einzelnen Beitrag anzeigen

the_source

Registriert seit: 16. Jun 2006
12 Beiträge
 
#10

Re: Variablen sortieren

  Alt 17. Jun 2006, 11:09
hmm, also ich habs jetzt mal provisorisch gemacht mit nen labels, aber das ist nicht das Problem.
Das Problem besteht darin, dass ich am Ende für jeden Buchstaben die Häufigkeit "0" rausbekomme. Der "counterDEF", der die Anzahl aller zulässigen Buchstaben zählt, stimmt.

Ich verstehe einfach nict, woran es liegt.

Delphi-Quellcode:
procedure TForm1.StartClick(Sender: TObject);
 var
  s:String;
  counterMAIN:Integer;
  counterSET:Integer;
  counterCHAR:Integer;
  countDEF:Integer;
  laenge:Integer;
  countArray: Array[1..26] of Integer;
 begin
  for counterSET:= 1 to 26 do
   begin
    countArray[counterSET]:= 0;
   end;
  countDEF:= 0;
  s:= eingabe.Text;
  laenge:= Length(s);
  ProgressBar1.Max:= laenge;
   for counterMAIN:= 1 to laenge do
    begin
     for counterCHAR:= 65 to 90 do
      begin
       if UpperCase(s[counterMAIN]) = CHR(counterCHAR) then
        begin
         countArray[counterCHAR]:= countArray[counterCHAR] + 1;
         countDEF:= countDEF + 1;
        end;
      end;
     ProgressBar1.Position:= ProgressBar1.Position + 1;
    end;
  OutA.Caption:= IntToStr(countArray[1]);
  OutB.Caption:= IntToStr(countArray[2]);
  OutC.Caption:= IntToStr(countArray[3]);
  OutD.Caption:= IntToStr(countArray[4]);
  OutE.Caption:= IntToStr(countArray[5]);
  OutF.Caption:= IntToStr(countArray[6]);
  OutG.Caption:= IntToStr(countArray[7]);
  OutH.Caption:= IntToStr(countArray[8]);
  OutI.Caption:= IntToStr(countArray[9]);
  OutJ.Caption:= IntToStr(countArray[10]);
  OutK.Caption:= IntToStr(countArray[11]);
  OutL.Caption:= IntToStr(countArray[12]);
  OutM.Caption:= IntToStr(countArray[13]);
  OutN.Caption:= IntToStr(countArray[14]);
  OutO.Caption:= IntToStr(countArray[15]);
  OutP.Caption:= IntToStr(countArray[16]);
  OutQ.Caption:= IntToStr(countArray[17]);
  OutR.Caption:= IntToStr(countArray[18]);
  OutS.Caption:= IntToStr(countArray[19]);
  OutT.Caption:= IntToStr(countArray[20]);
  OutU.Caption:= IntToStr(countArray[21]);
  OutV.Caption:= IntToStr(countArray[22]);
  OutW.Caption:= IntToStr(countArray[23]);
  OutX.Caption:= IntToStr(countArray[24]);
  OutY.Caption:= IntToStr(countArray[25]);
  OutZ.Caption:= IntToStr(countArray[26]);
  OutGES.Caption:= IntToStr(countDEF);
 end;
[edit=Sharky]Delphi-Tags gesetzt. Mfg, Sharky[/edit]
  Mit Zitat antworten Zitat