title: Convert String to Byte in VB6 with &H81 included in 0th index
body: <p>How to Convert string in to Byte array that contain &amp;H81 in first index if the byte array mybyte(0) with</p>
  
  <p>i need to check in my byte array</p>
  
  <pre><code>Private Declare Sub CopyMemory _
              Lib "kernel32" _
              Alias "RtlMoveMemory" (Destination As Any, _
                                     Source As Any, _
                                     ByVal Length As Long)
  </code></pre>
  
  <hr>
  
  <pre><code>Private Sub cmdCommand1_Click()
      Dim str  As String
      Dim BT() As Byte
  
     BT() = StrToByte(tbMsg.Text)
  
     If BT(0) = &amp;H81 Then
        'MyCode
     End If
  
  End Sub
  </code></pre>
  
  <blockquote>
    <p>the   If mybyte(0) = &amp;H81 Then condition is allays getting false</p>
  </blockquote>
  
  <p>and currently i'm using this string to byte converting method</p>
  
  <pre><code>Public Function StrToByte(strInput As String) As Byte()
      Dim lPntr    As Long
      Dim bTmp()   As Byte
      Dim bArray() As Byte
  
      If Len(strInput) = 0 Then Exit Function
          ReDim bTmp(LenB(strInput) - 1) 'Memory length
          ReDim bArray(Len(strInput) - 1) 'String length
          CopyMemory bTmp(0), ByVal StrPtr(strInput), LenB(strInput)
  
      For lPntr = 0 To UBound(bArray)
  
          If bTmp(lPntr * 2 + 1) &gt; 0 Then
              bArray(lPntr) = Asc(Mid$(strInput, lPntr + 1, 1))
          Else
              bArray(lPntr) = bTmp(lPntr * 2)
          End If
      Next lPntr
  
     StrToByte = bArray
  End Function
  </code></pre>