DescArray: array[1..36] of Char = ('0','1','2','3','4','5','6', '7','8','9','A','B','C','D', 'E','F','G','H','I','J','K', 'L','M','N','O','P','Q','R', 'S','T','U','V','W','X','Y','Z');
procedure TForm1.GdataClick(Sender: TObject); //Beregner fra seriel nummer til uniqe ID var C1,C2,C3,C4,Serial1,cur:Integer;
begin Serial1:= StrToInt(Sernum.Text); // C1 til C4 = char C1 := (SerIal1-10000000) div(36*36*36); begin C2 :=((Serial1-10000000)-(36*36*36*c1)) DIV (36*36); begin C3 :=((Serial1-10000000)-(36*36*36*C1)- (36*36*c2)) DIV 36; begin C4 :=((Serial1 -10000000)-(36*36*36*C1)-(36*36*C2)) - (36*c3) ; // Beregning begin Cur := C1; if Cur = 26 then Cur := -1; C1 := Cur ; Cha1 := DesArray[C1 + 1]; // Char 1 begin Cur := C2; if Cur = 36 then Cur := -1; C2 := Cur ; Cha2:= DescArray[C2 + 1]; // Char 2 begin Cur := C3; if Cur = 36 then Cur := -1; C3 := Cur ; Cha3 := DescArray[C3 + 1]; // Char 3 begin Cur := C4; if Cur = 36 then Cur := -1; C4 := Cur ; Cha4 := DescArray[C4 + 1]; // Char 4 globalID.text:=(cha1+cha2+cha3+cha4); crtID.text:=(cha1+cha2+cha3+cha4); end;end;end;end;end;end;end;
DescArray: array[1..36] of Char = ('0','1','2','3','4','5','6', '7','8','9','A','B','C','D', 'E','F','G','H','I','J','K', 'L','M','N','O','P','Q','R', 'S','T','U','V','W','X','Y','Z'); type TForm1 = class(TForm) GDataClick: TButton; Sernum: TEdit; globalid: TEdit; crtid: TEdit; procedure GdataClick(Sender: TObject); private { Private declarations } public { Public declarations } end;
var Form1: TForm1;
implementation
{$R *.DFM}
//Beregner fra seriel nummer til uniqe ID procedure TForm1.GdataClick(Sender: TObject); var C1,C2,C3,C4,Serial1,cur:Integer; cha1,cha2,cha3,cha4: char; begin Serial1:= StrToInt(Sernum.Text); // C1 til C4 = char C1 := (SerIal1-10000000) div(36*36*36); begin C2 :=((Serial1-10000000)-(36*36*36*c1)) DIV (36*36); begin C3 :=((Serial1-10000000)-(36*36*36*C1)- (36*36*c2)) DIV 36; begin C4 :=((Serial1 -10000000)-(36*36*36*C1)-(36*36*C2)) - (36*c3) ; // Beregning begin Cur := C1; if Cur = 26 then Cur := -1; C1 := Cur ; Cha1 := DesArray[C1 + 1]; // Char 1 begin Cur := C2; if Cur = 36 then Cur := -1; C2 := Cur ; Cha2:= DescArray[C2 + 1]; // Char 2 begin Cur := C3; if Cur = 36 then Cur := -1; C3 := Cur ; Cha3 := DescArray[C3 + 1]; // Char 3 begin Cur := C4; if Cur = 36 then Cur := -1; C4 := Cur ; Cha4 := DescArray[C4 + 1]; // Char 4 globalID.text:=(cha1+cha2+cha3+cha4); crtID.text:=(cha1+cha2+cha3+cha4); end;end;end;end;end;end;end;
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.