如何根据HEX转换并出原串?
这个简单
'繁体简体转换
'参数sStr为需要转换的文本
'参数iConver为要转化的类型,为1时表示繁体到简体的转换,为2时表示简体到繁体的
'转换
Public Function GBtoBIG5(sStr As String, iConver As Integer) As String
On Error Resume Next
Dim STR
If iConver = 1 Then 'BIG5-->GB
STR = StrConv(sStr, vbFromUnicode, &H804)
GBtoBIG5 = StrConv(STR, vbUnicode, &H404)
ElseIf iConver = 2 Then 'GB-->BIG5
STR = StrConv(sStr, vbFromUnicode, &H404)
GBtoBIG5 = StrConv(STR, vbUnicode, &H804)
End If
End Function
给你的函数改了改,简单些
Public Function HexToDec(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
HexToDec = B
End Function