Darthatron
Massive Troll
Ok, here are some pretty basic Hex Editing Functions for... Well... Hex Editing.
I have no idea why anyone here would want to use these functions, except maybe save file editing... Or something.
This is a Function thats get a string of Bytes...
Example of use:
________________________________________________
This next Function lets you write a single Byte into a file. If you could be bothered you could easily use it to make a 'WriteHEX' Function, but I am far too lazy and have no need for it.
Example of use:
________________________________________________
The following code flips a HEX string around. Sometimes in Binary Data to 'goto' a location you would put the actual location of the String, reversed. So... For the location &H123456 to 'goto' the location would be &H563412.
Example of use:
Hell... that's it, I'm too lazy to elaborate anymore.
Have fun Hex Editing! 
EDIT: Obviously nobody used these yet, because I used a function that I didn't include... Anyway, fixed it.
This is a Function thats get a string of Bytes...
Code:
Public Function ReadHEX(FilePath As String, Start As Long, Length As Long) As String
On Error Resume Next
Dim iFile As Long
Dim bytData As Byte
Dim sHex As String
Dim i As Long
Start = Start + 1
iFile = FreeFile
sHex = ""
i = 0
Open FilePath For Binary As iFile
For i = Start To (Start + Length - 1)
Get iFile, i, bytData
sHex = sHex & Right("00" & Hex(bytData), 2)
Next i
Close iFile
ReadHEX = sHex
End Function
Code:
strString = ReadHEX("C:\File.bin", 20542, 1)
This next Function lets you write a single Byte into a file. If you could be bothered you could easily use it to make a 'WriteHEX' Function, but I am far too lazy and have no need for it.
Code:
Public Function Write1Byte(FilePath As String, Start As Long, Data As String)
On Error Resume Next
Dim iFile As Long
Dim bytData As Byte
Start = Start + 1
iFile = FreeFile
Open FilePath For Binary As iFile
bytData = CInt("&H" & Right("00" & Data, 2))
Put iFile, Start, bytData
Close iFile
End Function
Code:
Write1Byte "C:\File.bin",, 20542, "FF"
The following code flips a HEX string around. Sometimes in Binary Data to 'goto' a location you would put the actual location of the String, reversed. So... For the location &H123456 to 'goto' the location would be &H563412.
Code:
Public Function ReverseHEX(HEXData As String) As String
Dim iNum As Long
Dim HEXHolder As String
If (Len(HEXData)) <> Int((Len(HEXData)) / 2) * 2 Then HEXData = "0" & HEXData
For iNum = 0 To Len(HEXData) + 1
If Len(HEXData) <= 1 Then GoTo EndNow
HEXHolder = HEXHolder & Right(HEXData, 2)
HEXData = Left(HEXData, Len(HEXData) - 2)
Next iNum
EndNow:
ReverseHEX = HEXHolder
End Function
Code:
strString = ReverseHEX("123456")
Hell... that's it, I'm too lazy to elaborate anymore.
EDIT: Obviously nobody used these yet, because I used a function that I didn't include... Anyway, fixed it.

