## Convert a Number from a certain base to a different one

I share my Code, as anticipated in the following thread:

Code:
```Function Convert•Num‹Num(Number As String, BaseNew_2Binary_8Octal_10Decimal_16Hexadecimal As Integer, BaseOld_2Binary_8Octal_10Decimal_16Hexadecimal As Integer, Optional QuantityDigitsToReturn As Integer) As String
'Pass a Number, from a certain Base, to another different Base
'The Number Parameter is actually a String that represents the input Number
'QuantityDigitsToReturn completes with 0 on the left so that the total number of digits of the number is as requested. If 0 is passed there will be no modifications
'Be careful: this amount cannot be less than the number of digits in the result, otherwise it will be truncated.
Dim Cad As String, BV As Integer, BN As Integer, DC As Integer
DC = QuantityDigitsToReturn
If DC > 0 Then Cad = Right(String(64, "0") & Cad, DC)
End Function

Function Convert•Dec‹Num(Number As String, BaseOld_2Binary_8Octal_16Hexadecimal As Integer) As String
'Go to Decimal (Base 10), a Number that is originally Binary (Base 2), Octal (Base 8) or Hexadecimal (Base 16)
Dim Ptr As Integer, DA As String, CD As Integer, B10 As Long, CA As Integer, Base As Integer
CD = Len(Trim(Number))
For Ptr = 1 To CD
DA = Mid(Number, Ptr, 1)
DA = UCase(DA)
CA = Asc(DA)
Select Case Base
Case 2:  If CA < 48 Or CA > 49 Then MsgBox ("Number specification error, if its base is binary"): Exit Function
Case 8:  If CA < 48 Or CA > 56 Then MsgBox ("Number specification error, if its base is octal"): Exit Function
Case 16: If CA < 48 Or (CA > 57 And CA < 65) Or (CA > 70) Then MsgBox ("Number specification error, if its base is hexadecimal"): Exit Function
End Select
If CA > 64 Then DA = "&H" & DA
B10 = B10 + Val(DA) * Base ^ (CD - Ptr)
Next
Convert•Dec‹Num = B10
End Function

Function Convert•Num‹Dec(Number As String, BaseNew_2Binary_8Octal_16Hexadecimal As Integer) As String
'Go to Binary (Base 2), Octal (Base 8) or Hexadecimal (Base 16), a Number that is originally Decimal (Base 10)
Dim DA As Integer, Cad As String, DR As Long, Base As Integer
DR = CLng(Trim(Number))
Do While DR > 0
DA = DR Mod Base
DR = DR \ Base
Loop