Public Function HEX_to_DEC(ByVal Hex As String) As Long
Dim i As Long
Dim B As Long
Hex = UCase(Hex)
For i = 1 To Len(Hex)
Select Case Mid(Hex, Len(Hex) - i + 1, 1)
Case "0": B = B + 16 ^ (i - 1) * 0
Case "1": B = B + 16 ^ (i - 1) * 1
Case "2": B = B + 16 ^ (i - 1) * 2
Case "3": B = B + 16 ^ (i - 1) * 3
Case "4": B = B + 16 ^ (i - 1) * 4
Case "5": B = B + 16 ^ (i - 1) * 5
Case "6": B = B + 16 ^ (i - 1) * 6
Case "7": B = B + 16 ^ (i - 1) * 7
Case "8": B = B + 16 ^ (i - 1) * 8
Case "9": B = B + 16 ^ (i - 1) * 9
Case "A": B = B + 16 ^ (i - 1) * 10
Case "B": B = B + 16 ^ (i - 1) * 11
Case "C": B = B + 16 ^ (i - 1) * 12
Case "D": B = B + 16 ^ (i - 1) * 13
Case "E": B = B + 16 ^ (i - 1) * 14
Case "F": B = B + 16 ^ (i - 1) * 15
End Select
Next i
HEX_to_DEC = B
End Function作者: leoyan76 时间: 2008-9-12 16:01
多谢,我也用了定义函数
Private Function C16To10(strA As String) As Double
Dim a As Double
Dim b As String
Dim c As Double
Dim l As Integer
Dim i As Long
l = Len(strA)
For i = 1 To l
b = Mid(strA, i, 1)
Select Case b
Case "A"
b = 10
Case "B"
b = 11
Case "C"
b = 12
Case "D"
b = 13
Case "E"
b = 14
Case "F"
b = 15
End Select
c = c + b * 16 ^ (l - 1)
l = l - 1
Next
C16To10 = c