Thursday, November 21, 2013

String & Byte Conversion

Something I would like to share after almost 20 months without any update. Function to convert string into byte and convert back into string if required.

Dim Devc As String
Dim status As Long
Dim i As Integer
Dim bytes() As Byte

Devc = "Hello World!"

'*** convert into byte ***
bytes = StrConv(Devc, vbFromUnicode)

Devc = ""

For i = LBound(bytes) To UBound(bytes)
    Devc = Devc & Format$(Hex$(bytes(i)), "00") & " "
Next i

Debug.Print Devc >>> 00 00 00 00 00 00 00 00 00 00 00

' *** convert into string ***
Devc = StrConv(bytes, vbUnicode)
Debug.Print Devc >>> Hello World!

No comments:

Post a Comment

komen mengomen dibenarkan disini

LinkWithin

Related Posts Plugin for WordPress, Blogger...