VBA怎么转化2进制为16进制?
如题..有没有什么函数可以之接用?或者自定义函数?
[解决办法]
自己写个函数:
Function BinToHex(ByVal sBin As String) As String Const BinChar = "0000000100100011010001010110011110001001101010111100110111101111" Dim i As Integer, j As Integer, s As String BinToHex = "" sBin = "000" & sBin sBin = Right(sBin, (Len(sBin) \ 4) * 4) For i = Len(sBin) \ 4 - 1 To 0 Step -1 s = Mid(sBin, i * 4 + 1, 4) For j = 0 To 14 If s = Mid(BinChar, j * 4 + 1, 4) Then Exit For Next j If j < 10 Then BinToHex = Chr(j + Asc("0")) + BinToHex Else BinToHex = Chr(j - 10 + Asc("A")) + BinToHex End If Next iEnd FunctionPrivate Sub Form_Load() Debug.Print BinToHex("10100101") EndEnd Sub