The code below will convert any 'number' starting in base [2..36] to base [2..36]

Example:

Code:
BaseToBaseConversion('49152',10,16,8) would return '0000FFFF'
common bases (if you are rusty):
base 2 = binary
base 8= octal
base 10 = decimal
base 16 = hexadecimal

or some not yet used base of your own (between 2 and 36) to encode values or similar.

[pascal]
Function BaseToBaseConversion(Const AInNumber : String;
Const AInBase,AOutBase : Byte;
Const AMinOutBaseDigits : Byte) : String;
// Inputs:
// AInNumber = input number to convert from (base 2 - 36)
// AInBase = input base number (2 - 36)
// AOutBase = input base number (2 - 36)
// AMinOutBaseDigits = minimum number of 'digits' to use in the output
string
//
// Outputs:
// Result = the AInNumber converted to the AOutBase base (if possible)
Const
cDigits = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';
Var
Decimal : LongInt;
Remainder : LongInt;
Power : Integer;
DigitValue : Integer;
Index : Integer;
Begin
Result := '';
If Not(AInBase In[2..36]) Then Exit;
If Not(AOutBase In[2..36]) Then Exit;
If AInNumber = '' Then Exit;
Decimal := 0;
Power := 1;
For Index := Length(AInNumber) Downto 1 Do
Begin
DigitValue := Pos(AInNumber[Index],cDigits) - 1;
If DigitValue < 0 Then Exit; // illegal input digit found so bomb out
Decimal := Decimal + Power * DigitValue;
Power := Power * AInBase;
End;
If Decimal = 0 Then
Result := cDigits[1]
Else
While Decimal <> 0 Do
Begin
Remainder := Decimal Mod AOutBase;
Decimal := Decimal Div AOutBase;
Result := cDigits[Remainder + 1] + Result;
End;
For Index := 1 To (AMinOutBaseDigits - Length(Result)) Do
Result := cDigits[1] + Result;
End;
[/pascal]