patriciaxxx
Programmer
I want to store hex strings in an Array and then compare a file to see if there is any match.
This is what I have so far.
My Array
My code to load a file Hex
The code returns the following for the sample below
01005374616E64617264204A657420444201000B56E362609C255E9A96772403F09C7E9F90FF859A31C579BAED30BCDFCC9D63D9E4C39F46FB8ABC4E8874EC3753CB9CFAC8D128E61D398A605A1B7B36FBFDDFB1797B1343C120B1333AEE795B9C3A7C2A6AFA7C9981F98FD80BFE050BBDF81665F95F8D089248567C61F2744D2EECF65EDFF7C746A17816CEDE92D62D454600342E300 and so on…ie the rest of the file hex
1. I need the code to return the hex string with all the zeros.
2. I need the code to have a byte setting I can set to the number of bytes I want to retun in this case 160
A sample hex string for the Array
This sample is 160 bytes. I will keep all the Array hex strings at 160 bytes to make the comparisons easier.
3. I need a simple way to strip out the spaces.
00 01 00 00 53 74 61 6E 64 61 72 64 20 4A 65 74 20 44 42 00 01 00 00 00 B5 6E 03 62 60 09 C2 55 E9 A9 67 72 40 3F 00 9C 7E 9F 90 FF 85 9A 31 C5 79 BA ED 30 BC DF CC 9D 63 D9 E4 C3 9F 46 FB 8A BC 4E F5 59 EC 37 2E E6 9C FA B5 FC 28 E6 60 14 8A 60 27 36 7B 36 86 D0 DF B1 04 56 13 43 BC 0D B1 33 47 C3 79 5B E1 17 7C 2A 22 D4 7C 99 08 1F 98 FD 81 7E 91 58 19 70 84 66 5F 95 F8 D0 89 24 85 67 C6 1F 27 44 D2 EE CF 65 ED FF 07 C7 46 A1 78 16 0C ED E9 2D 62 D4 54 06 00 00 34 2E 30 00
4. I need to compare the input file with the Array and return any match.
Any help on the 4 points would be much appreciated.
This is what I have so far.
My Array
Code:
Dim DataHold(50, 2) As Variant
DataHold(1, 1) = "This would be first hex string"
DataHold(1, 2) = "This would be first hex string description to display if match is true"
DataHold(2, 1) = "This would be second hex string"
DataHold(2, 2) = "This would be second hex string description to display if match is true"
DataHold(3, 1) = "This would be third hex string"
DataHold(3, 2) = "This would be third hex string description to display if match is true"
'and so on...
My code to load a file Hex
Code:
Function GetFileHex()
Dim intFileNumber As Integer
Dim lngFileSize As Long
Dim strBuffer As String
Dim lngCharNumber As Long
Dim strCharacter As String * 1
Dim strFileName As String
strFileName = CurrentProject.path & "\Test.mdb"
intFileNumber = FreeFile
DoCmd.Hourglass True
Open strFileName For Binary Access Read Shared As #intFileNumber
lngFileSize = LOF(intFileNumber)
strBuffer = Space$(lngFileSize)
Get #intFileNumber, , strBuffer
Close #intFileNumber
For lngCharNumber = 1 To lngFileSize
strCharacter = Mid(strBuffer, lngCharNumber, 1)
Dim strHex As String
strHex = strHex & Hex(asc(strCharacter))
Next
Debug.Print strHex
DoCmd.Hourglass False
End Function
The code returns the following for the sample below
01005374616E64617264204A657420444201000B56E362609C255E9A96772403F09C7E9F90FF859A31C579BAED30BCDFCC9D63D9E4C39F46FB8ABC4E8874EC3753CB9CFAC8D128E61D398A605A1B7B36FBFDDFB1797B1343C120B1333AEE795B9C3A7C2A6AFA7C9981F98FD80BFE050BBDF81665F95F8D089248567C61F2744D2EECF65EDFF7C746A17816CEDE92D62D454600342E300 and so on…ie the rest of the file hex
1. I need the code to return the hex string with all the zeros.
2. I need the code to have a byte setting I can set to the number of bytes I want to retun in this case 160
A sample hex string for the Array
This sample is 160 bytes. I will keep all the Array hex strings at 160 bytes to make the comparisons easier.
3. I need a simple way to strip out the spaces.
00 01 00 00 53 74 61 6E 64 61 72 64 20 4A 65 74 20 44 42 00 01 00 00 00 B5 6E 03 62 60 09 C2 55 E9 A9 67 72 40 3F 00 9C 7E 9F 90 FF 85 9A 31 C5 79 BA ED 30 BC DF CC 9D 63 D9 E4 C3 9F 46 FB 8A BC 4E F5 59 EC 37 2E E6 9C FA B5 FC 28 E6 60 14 8A 60 27 36 7B 36 86 D0 DF B1 04 56 13 43 BC 0D B1 33 47 C3 79 5B E1 17 7C 2A 22 D4 7C 99 08 1F 98 FD 81 7E 91 58 19 70 84 66 5F 95 F8 D0 89 24 85 67 C6 1F 27 44 D2 EE CF 65 ED FF 07 C7 46 A1 78 16 0C ED E9 2D 62 D4 54 06 00 00 34 2E 30 00
4. I need to compare the input file with the Array and return any match.
Any help on the 4 points would be much appreciated.