Buscamos en distintos espacios y así brindarte la respuesta a tu dilema, en caso de alguna inquietud déjanos la inquietud y respondemos porque estamos para ayudarte.
Ejemplo 1: excel vba binario a hexadecimal
'Fast VBA function to convert binary string to hexadecimal string...Function BinToHex$(bin$,Optional groupBy&=1)Dim c&, i&, j&, hNdx&, nibble&, bits$, s$Dim b()AsByte, h()AsByteStatic bHexChars()AsByte, pow2()AsByteConst HEX_CHARS$="0123456789ABCDEF"If(NotNot bHexChars)=0Then bHexChars = StrConv(HEX_CHARS, vbFromUnicode)If(NotNot pow2)=0Then pow2 = ChrW$(&H201)& ChrW$(&H804)
b = StrConv(bin, vbFromUnicode)ReDim h(0To-Int(-Len(bin)/4)-1)
hNdx = UBound(h)For i = UBound(b)To0Step-1If b(i)=49&Then nibble = nibble + pow2(c)
c = c +1If c =4Then
h(hNdx)= bHexChars(nibble)
hNdx = hNdx -1
nibble =0
c =0EndIfNextIf c Then h(hNdx)= bHexChars(nibble)
BinToHex = StrConv(h, vbUnicode)If groupBy >1Then
i = Len(BinToHex)+1Do
i = i - groupBy
If i <1Then
s =" "& Mid$(BinToHex,1, i + groupBy -1)& s
ExitDoEndIf
s =" "& Mid$(BinToHex, i, groupBy)& s
LoopWhile i
BinToHex = Trim$(s)EndIfEndFunction'-------------------------------------------------------------------------------
binaryStr ="11111100110101011110001101000110"
MsgBox BinToHex(binaryStr)'<--displays: FCD5E346
MsgBox BinToHex(binaryStr,4)'<--displays: FCD5 E346
MsgBox BinToHex(binaryStr,2)'<--displays: FC D5 E3 46'Note: this is an extremely fast and optimized function that can convert' an arbitrarily large binary string to hex.'''
Ejemplo 2: excel vba binary to hexadecimal
'Extremely fast VBA function to convert a binary string to a 16-bit Integer:Function BitsToInteger%(bits$)Dim i&Static b()AsByteIf LenB(bits)>32ThenExitFunctionIf LenB(bits)=32Then
b = bits
Else
b =String$(16- Len(bits),"0")& bits
EndIfFor i =2To30Step2
BitsToInteger =2* BitsToInteger Or(b(i)Xor48)NextIf(b(0)Xor48)Then BitsToInteger = BitsToInteger Or&H8000EndFunction'Example:
MsgBox BitsToInteger("1111111111111111")'<--displays: -1
MsgBox BitsToInteger("0111111111111111")'<--displays: 32767
Ejemplo 3: excel vba binary to hexadecimal
'Extremely fast VBA function to convert a binary string to a Byte:Function BitsToByte(bits$)AsByteDim i&Static b()AsByteIf LenB(bits)>16ThenExitFunctionIf LenB(bits)=16Then
b = bits
Else
b =String$(8- Len(bits),"0")& bits
EndIfFor i =0To14Step2
BitsToByte =2* BitsToByte Or(b(i)Xor48)NextEndFunction'Example:
MsgBox BitsToByte("00001100")'<--displays: 12
MsgBox BitsToByte("10000001")'<--displays: 129'''
¡Haz clic para puntuar esta entrada!
(Votos: 0 Promedio: 0)