Imports System.Text
And then add the functions:
Private Function ConvertBytesToString(ByVal bytes As Byte()) As String
Return ASCIIEncoding.ASCII.GetString(bytes)
End Function
Private Function ConvertStringToBytes(ByVal str As String) As Byte()
Return ASCIIEncoding.ASCII.GetBytes(str)
End Function
You can use it as this:
'This is how you convert string to bytes array
Dim Data() As Byte = ConvertStringToBytes("String to be converted")
'And this is the reverse one
Dim STR As String = ConvertBytesToString(Data)
No comments:
Post a Comment