regent
asked on
Scientific Number Conversions
I need to convert a hex, octal, or binary number to DECIMAL. How can I do this? I know about the Hex and Oct functions, and can figure out decimal to binary, I just don't know how to get the number (string) back to decimal. Also, if anyone has sample code for creating a scientific calculator (specifically the number conversions), I'd REALLY like to see it (and I'd pay extra points).
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Lonnie Brooke
Public Function HexToDecimal(HexNumber As String) As Long
Dim tmpAr() As Byte
Dim i&, j&, k&, t&, r&
Dim l$, m$
i = Len(HexNumber)
ReDim tmpAr(i) As Byte
j = 1
k = i - 1
While j < i + 1
t = Asc(Mid(HexNumber, j, 1))
Select Case t
Case 65 To 70
t = t - 55
Case 48 To 57
t = t - 48
End Select
r = r + ((16 ^ k) * t)
k = k - 1
j = j + 1
Wend
HexToDecimal = r
End Function