hello..
I Just need to convert A huge amount of Hex to ByteArray ..
i have one awesome function written by Merri ..
Here it is ..
The problem is that on some computers converting takes a lot of time andCode:Public Function HexStringToByteArray(ByRef HexString As String) As Byte() Dim bytOut() As Byte, bytHigh As Byte, bytLow As Byte, lngA As Long If LenB(HexString) Then ' preserve memory for output buffer ReDim bytOut(Len(HexString) \ 2 - 1) ' jump by every two characters (in this case we happen to use byte positions for greater speed) For lngA = 1 To LenB(HexString) Step 4 ' get the character value and decrease by 48 bytHigh = AscW(MidB$(HexString, lngA, 2)) - 48 bytLow = AscW(MidB$(HexString, lngA + 2, 2)) - 48 ' move old A - F values down even more If bytHigh > 9 Then bytHigh = bytHigh - 7 If bytLow > 9 Then bytLow = bytLow - 7 ' I guess the C equivalent of this could be like: *bytOut[++i] = (bytHigh << 8) || bytLow bytOut(lngA \ 4) = (bytHigh * &H10) Or bytLow Next lngA ' return the output HexStringToByteArray = bytOut End If End Function
sometimes it doesn't even work ..
any help please to mod this function making it a little faster ..
thanks in advance .. and sorry for my bad english ..




Reply With Quote