title: How convert Hex String into Byte Array in VB6
body: <p>I have the following byte array.</p>
  
  <pre><code>Dim Template(1023) As Byte
  </code></pre>
  
  <p>Then i call the fingerprint scanner device function and returns the following:</p>
  
  <pre><code>Template(0) = 70
  Template(1) = 77
  Template(2) = 82
  ...
  Template(1023) = 0
  </code></pre>
  
  <p>Then i convert the Bytes array into a string hex as follows (view attached image):</p>
  
  <pre><code>Dim n As Long, i As Long
  ByteArrayToHexStr = Space$(3 * (UBound(Template) - LBound(Template)) + 2)
  n = 1
  For i = LBound(Template) To UBound(Template)
       Mid$(ByteArrayToHexStr, n, 2) = Right$("00" &amp; Hex$(b(i)), 2)
      n = n + 3
  Next
  </code></pre>
  
  <p><a href="http://i.stack.imgur.com/xx8nC.png" rel="nofollow">Byte Array converted into Hex String</a>
  How can i convert the hex string into a byte array again?</p>
  
  <p>Thanks!!</p>