locked
how to do vb.net replace on a byte array RRS feed

  • Question

  • User1682543174 posted

    I have a byte array of data. How can I find and replacement a part of the byte array with replacement data?

    dim foo as byte foo = MY DATA

    If foo was a string, then I would do: foo = replace( foo, target, replacement )

    But foo is a byte array. How can I replace?

    Tuesday, September 30, 2014 1:13 AM

All replies

  • User-821857111 posted

    You can just loop through the elements of the array and reset the values of the ones you want to change:

    For i = 0 To foo.Length - 1
        If foo(i) = some_value_you_want_to_change Then foo(i) = replacement_value
    Next



    Tuesday, September 30, 2014 2:37 AM
  • User1682543174 posted

    This cannot work.  There's a different # of replacement bytes.

    Tuesday, September 30, 2014 9:03 AM
  • User-821857111 posted

    This cannot work

    Yes it can. But not for your current requirement, whatever that is.

    Tuesday, September 30, 2014 9:52 AM