Highlights
All Snippets
Top 100 Snippets
Librarians
gbCodeLib

By Language
VB6
JavaScript
Perl
HTML
SQL
Java
DOS

GBIC >> Source Code >> Visual Basic >> Snippet

Convert Byte array to string


'use to handle Byte arrays returned from API

Public Function ByteArrayToString(bytArray() As Byte ) As String
Dim i As Long
ByteArrayToString = StrConv(bytArray, vbUnicode)
i = InStr(sAns, Chr (0))
If i > 0 Then ByteArrayToString = Left(sAns, iPos - 1)
End Function


'=====================
'more information on Byte arrays and strings:

Dim B(10) As Byte    'byte arry
Dim VarString As   String   'string

'this puts a zero in every other element
B = VarString        

'this returns a byte array with only the character codes (no chr$(0) every other element
B = StrConv(VarString, vbFromUnicode)