Thema: Delphi Nummerierung

Einzelnen Beitrag anzeigen

Benutzerbild von robinWie
robinWie

Registriert seit: 26. Okt 2005
Ort: Lippcity
404 Beiträge
 
Delphi 2005 Personal
 
#1

Nummerierung

  Alt 26. Aug 2006, 16:50
Hallo,
wer kennt das nicht. Man will etwas Nummerieren aber der Explorer zeigt, bei einfacher nummerierung, die Dateien so an:
Code:
1Datei
10Datei
11Datei
2Datei
3Datei
4Datei
5Datei
6Datei
7Datei
8Datei
9Datei
Das hat mich sehr gestört. Da habe ich einen Algo geschrieben der das ganze so Nummeriert:
Code:
01. Datei
02. Datei
03. Datei
04. Datei
05. Datei
06. Datei
07. Datei
08. Datei
09. Datei
10. Datei
11. Datei
Hier iser
Leider unterstüzt er "nur" maximal 1.000.000 Einträge
Delphi-Quellcode:
function GetNumber(Position, Max: integer): string;
var
 NOM: string;
begin
      if Length(IntToStr(Position+1))=1 then begin
         if Max >= 100000 then
            NOM:='00000'+IntToStr(Position+1)+'. ';
         if (Max>=10000) and (Max <100000) then
            NOM:='0000'+IntToStr(Position+1)+'. ';
         if (Max>=1000) and (Max<10000) then
            NOM:='000'+IntToStr(Position+1)+'. ';
         if (Max>=100) and (Max<1000) then
            NOM:='00'+IntToStr(Position+1)+'. ';
         if (Max>=10) and (Max<100) then
            NOM:='0'+IntToStr(Position+1)+'. ';
         if (Max>=1) and (Max<10) then
            NOM:=IntToStr(Position+1)+'. ';
       end;
       if Length(IntToStr(Position+1))=2 then begin
         if Max >=10000 then
            NOM:='0000'+IntToStr(Position+1)+'. ';
         if (Max>=10000) and (Max <10000) then
            NOM:='000'+IntToStr(Position+1)+'. ';
         if (Max>=1000) and (Max<10000) then
            NOM:='00'+IntToStr(Position+1)+'. ';
         if (Max>=100) and (Max<1000) then
            NOM:='0'+IntToStr(Position+1)+'. ';
         if Max<100 then
            NOM:=IntToStr(Position+1)+'. ';
       end;
       if Length(IntToStr(Position+1))=3 then begin
         if Max>=100000 then
            NOM:='000'+IntToStr(Position+1)+'. ';
         if (Max>=10000) and (Max <100000)then
            NOM:='00'+IntToStr(Position+1)+'. ';
         if (Max>=1000) and (Max<10000) then
            NOM:='0'+IntToStr(Position+1)+'. ';
         if Max<1000 then
            NOM:=IntToStr(Position+1)+'. ';
       end;
       if Length(IntToStr(Position+1))=4 then begin
         if Max>=100000 then
            NOM:='00'+IntToStr(Position+1)+'. ';
         if (Max>=10000) and (Max<100000) then
            NOM:='0'+IntToStr(Position+1)+'. ';
         if (Max>=1000) and (Max<10000) then
            NOM:=IntToStr(Position+1)+'. ';
       end;
       if Length(IntToStr(Position+1))=5 then begin
         if Max>=100000 then
          NOM:='0'+IntToStr(Position+1)+'. ';
       end;
       if Length(IntToStr(Position+1))=6 then begin
         if Max>=100000 then
            NOM:=IntToStr(Position+1)+'. ';
       end;
  Result := Nom;
end;
Robin W.
Ein Computer kann (fast) alles.... Man muss es ihm nur beibringen
  Mit Zitat antworten Zitat