//// 我使用27進制實現這個
var
Form2: TForm2;
implementation
uses math, StrUtils;
{$R *.dfm}
// XSystem = '123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
// max 62 System
// XSystem = '0123456789abcdefghijklmnopqrstuvwxyz';
// max 62 System
// xx = 36;
XSystem: string = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0';
xx: integer = 27;
function XSystemToDec(v: string;
nSystem: byte): Int64;
var
i, p: integer;
begin
result := 0;
p := 0;
for i := length(v) do
wnto 1 do
begin
result := result + pos(v, xSystem) * trunc(power(nSystem, p));
inc(p);
end;
end;
function DecToXSystem(v: Int64;
nSystem: byte): string;
var
m: int64;
p: integer;
begin
result := '';
while v > 0 do
begin
p := v mod nSystem;
// 1, 27
if p = 0 then
p := 1;
// cary
result := XSystem[p] + result;
v := v div nSystem;
// 27 div 27 = 1
end;
end;
procedure TForm2.FormCreate(Sender: TObject);
var
a, b, i: integer;
begin
a := xsystemtodec('A', xx);
b := xsystemtodec('ZZZ', xx);
for i := a to b do
listbox1.Items.Add( DecToXSystem(i, xx) );
end;