William,
Strings don't really have binary data in them, at least they should not
really contain binary data. Strings have Unicode characters in them.
If this is related to your previous question, I would alter the DecodeString
function to return a Byte Array instead of a String.
Something like (untested, syntax checked only).
Private Shared Function DecodeString3(ByVal InString As String, ByVal
Bytes As Integer) As Byte()
Dim output As New MemoryStream(InString.Length * 3 \ 4)
Dim x0, x1, x2 As Integer 'These are the chars that will be spit out
Dim y0, y1, y2, y3 As Integer 'These are what we got in
For i As Integer = 0 To Len(InString) - 1 Step 4
y0 = AscW(InString.Chars(i)) 'Get 4 chars and put into 'y's
y1 = AscW(InString.Chars(i + 1))
y2 = AscW(InString.Chars(i + 2))
y3 = AscW(InString.Chars(i + 3))
If (y0 = 96) Then y0 = 32 'If char is 96 then set to 2
If (y1 = 96) Then y1 = 32
If (y2 = 96) Then y2 = 32
If (y3 = 96) Then y3 = 32
x0 = ((y0 - 32) << 2) + ((y1 - 32) >> 4) 'Calculate the 3 chars
x1 = ((y1 Mod 16) << 4) + ((y2 - 32) >> 2)
x2 = ((y2 Mod 4) << 6) + (y3 - 32)
output.WriteByte(CByte(x0))
output.WriteByte(CByte(x1))
output.WriteByte(CByte(x2))
Next i
Return output.GetBuffer()
End Function
Which actually makes much more sense!
Hope this helps
Jay