I try to use the following code to convert an ASCII string into String. However, always results type mismatch as a result.
Dim result As String
Dim ch As Integer
Dim bin As String
Dim i As Integer
txt = txtAscii.Text
‘ txt = Replace(txt, vbCr, “”)
‘ txt = Replace(txt, vbLf, “”)
result = “”
For i = 1 To Len(txt)
ch = Left$(txt, 0)
i = i + 2
‘ ch = Mid$(txt, i, 1)
bin = Chr(ch) ‘—-Type mismatch—-
‘ bin = LongToBinary(Asc(ch), False)
result = result & Right$(bin, 2)
Next i
txtBinary.Text = result
End Sub