Question
April 25, 2008 at 01:02 AM
cora.kn.kwok

How to convert ASCII into string in VB6

by cora.kn.kwok . Updated 18 years, 4 months ago

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

This discussion is locked

All Comments