0

I have the code below:

Dim base64Decoded As String
Dim base64Encoded As String = "aGVsbG8="
Dim data As Byte()
data = System.Text.ASCIIEncoding.ASCII.GetBytes(base64Encoded)
base64Decoded = System.Convert.FromBase64String(data)
MsgBox(base64Decoded)

However, I'm getting an error message at the base64Decoded = ... line:

Value of type 'Byte()' cannot be converted to 'String'.

Any ideas?

1
  • it looks like you didn't get your informed badge until know, just feel free to read the Tour Page to learn more about Stackoverflow: Upvoting, accepting answers, asking good questions,... and to get your informed badge Commented Dec 17, 2017 at 15:45

1 Answer 1

1

First of all, you have to convert this string to an array of bytes using System.Convert.FromBase64String then convert it to String using System.Text.ASCIIEncoding.ASCII.GetString , FromBase64String take a string as parameter. Just try the following:

base64Decoded = System.Text.ASCIIEncoding.ASCII.GetString(System.Convert.FromBase64String(base64Encoded))

in your case aGVsbG8= will be converted to:

hello

Reference

Sign up to request clarification or add additional context in comments.

1 Comment

@AndrewMorton i fixed the error, now it is working. Thx for the remark

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.