Results 1 to 5 of 5

Thread: [RESOLVED] [help] VB6, How to search/replace a pattern in the byte array?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2018
    Posts
    64

    Resolved [RESOLVED] [help] VB6, How to search/replace a pattern in the byte array?

    Used the code below to read a binary file into byte array.

    Code:
    Private Sub cmdTest_Click()
        Dim fileNum As Integer
        Dim bytes() As Byte
    
        fileNum = FreeFile
        Open "C:\users\xxxx\desktop\wp.bin" For Binary As fileNum
        ReDim bytes(LOF(fileNum) - 1)
        Get fileNum, , bytes
        Close fileNum
    End Sub
    How can I search/replace a pattern in bytes() ?

  2. #2
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    5,909

    Re: [help] VB6, How to search/replace a pattern in the byte array?

    You can loop through the byte array and check each byte value.
    If it matches the first byte of the pattern then check the next byte for second byte in the pattern, and so on and so on.

  3. #3

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Mar 2018
    Posts
    64

    Re: [help] VB6, How to search/replace a pattern in the byte array?

    Quote Originally Posted by Arnoutdv View Post
    You can loop through the byte array and check each byte value.
    If it matches the first byte of the pattern then check the next byte for second byte in the pattern, and so on and so on.
    Sure, got it, thank you.

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Mar 2018
    Posts
    64

    Re: [help] VB6, How to search/replace a pattern in the byte array?

    Wow, your code is good and has high efficiency, thank you very much.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width