M
Mike
Folks, I know there has to better a built-in VB.NET for converting a
byte array of asciiz strings to a string array. This works, but is
there method to do this already?
// Convert buffer of fixed size asciiz strings to string array
Function B2S(_
ByVal count As Integer,_ ' number of items
ByVal size As Integer, _ ' size of asciiz
ByVal buffer() As Byte _ ' byte buffer
) As String()
Dim list(count - 1) As String
Dim n As Integer = 0
Dim i As Integer = 0
For n = 0 To count - 1
Dim s As String = ""
For i = 0 To size - 1
Dim b As Byte = buffer(n * size + i)
If b = 0 Then Continue For
s = s + Chr(b)
Next
list(n) = s
Next
Return list
End Function
Example use:
dim count as integer = 8
dim size as integer = 24
Dim data As Byte() = New Byte(count*size - 1) {}
GetMyDLLData(count, size, data)
dim alist() as string = B2S(count,size,data)
TIA
--
byte array of asciiz strings to a string array. This works, but is
there method to do this already?
// Convert buffer of fixed size asciiz strings to string array
Function B2S(_
ByVal count As Integer,_ ' number of items
ByVal size As Integer, _ ' size of asciiz
ByVal buffer() As Byte _ ' byte buffer
) As String()
Dim list(count - 1) As String
Dim n As Integer = 0
Dim i As Integer = 0
For n = 0 To count - 1
Dim s As String = ""
For i = 0 To size - 1
Dim b As Byte = buffer(n * size + i)
If b = 0 Then Continue For
s = s + Chr(b)
Next
list(n) = s
Next
Return list
End Function
Example use:
dim count as integer = 8
dim size as integer = 24
Dim data As Byte() = New Byte(count*size - 1) {}
GetMyDLLData(count, size, data)
dim alist() as string = B2S(count,size,data)
TIA
--