1

I want to convert characters like,

Dim Str as String = **Chr(198) & Chr(233) & "ÿ¤"**

Now I want to convert back Str to its character codes.

I am using this code:

Dim Bt(Str.Length - 1) As Byte
For i = 0 To Bt.Length - 1
    Bt(i) = Asc (Str(i)) ' Using the Asc() function
Next

Is there a better way to do this?

1 Answer 1

1

You could use LINQ:

Dim bt = Str.ToCharArray().Select(Function(x) Convert.ToByte(x)).ToArray()
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.