View Single Post
Old May 18th, 2008 (8:57 AM). Edited May 18th, 2008 by ThuGie.
Join Date: May 2008
Posts: 21
I checked out your function "ReverseHex",
And to tell you the truth it gave me the creeps :p,

First i noticed that when you run this its a example
Dim test As String
test = "01"
test will be empty after your function has been used,
And your for loop well you did add a break to it but stil you make it run 2 times it actually needs to loop.
But here's my remake of it.

Public Function ReverseHex(HexData As String) As String
Dim i As Integer
Dim Temp As String
Dim HexHold As String

HexHold = HexData

    If InStr(Len(HexHold) / 2, ",") > 0 Then HexHold = "0" & HexHold

    For i = 0 To (Len(HexHold) / 2) - 1
        Temp = Left(Right(HexHold, Len(HexHold) - (i * 2)), 2) & Temp
    Next i
ReverseHex = Temp
End Function
I was bored anyway :-),
And dont say i simple made a copy of your and changed it a bit.
I didnt do any speed check but it should be faster.
At least i think its cleaner that your current one.

Changed a small thing,
Still if your using mine updating would be smart.
Since now it wont alter the input data at all!
Reply With Quote