View Single Post
  #72    
Old May 18th, 2008, 08:57 AM
ThuGie
Beginning Trainer
 
Join Date: May 2008
Hey,
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
Code:
Dim test As String
test = "01"
msgbox(ReverseHex(test))
msgbox(test)
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.

Code:
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.

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

Last edited by ThuGie; May 18th, 2008 at 09:18 AM.
Reply With Quote