F
frekster
Hi.
I used to be able to do this easily in vb 6 via looping and preserving
the source array data/size etc.
How can I do this in vb.net? I've been trying for a while now and this
should be an easy task but it just isn't clicking.
For some reason, the preserve doesn't seem to be working.
I have a function where I pass it the source array of bytes and
destination array of bytes and it is to combine them.
CompletedFile is the array to hold the two combined byte arrays and is
used as the destination in the function call:
CompletedFile = Me.CombineByteArray(SourceFile, CompletedFile)
Private Function CombineByteArray(ByVal Source() As Byte, ByVal
Destination() As Byte) As Byte()
Dim intCurrPosition As Integer
Dim i As Integer
intCurrPosition = Destination.Length - 1
ReDim Preserve Destination(Destination.Length + Source.Length)
Try
For i = 0 To Source.Length - 1
Destination(intCurrPosition) = Source(i)
intCurrPosition = intCurrPosition + 1
Next
Return Destination
Catch ex As Exception
End Try
End Function
The above code is keeping the first byte array and not combining the
second byte array even though there are no errors.
Any ideas?
Justin
I used to be able to do this easily in vb 6 via looping and preserving
the source array data/size etc.
How can I do this in vb.net? I've been trying for a while now and this
should be an easy task but it just isn't clicking.
For some reason, the preserve doesn't seem to be working.
I have a function where I pass it the source array of bytes and
destination array of bytes and it is to combine them.
CompletedFile is the array to hold the two combined byte arrays and is
used as the destination in the function call:
CompletedFile = Me.CombineByteArray(SourceFile, CompletedFile)
Private Function CombineByteArray(ByVal Source() As Byte, ByVal
Destination() As Byte) As Byte()
Dim intCurrPosition As Integer
Dim i As Integer
intCurrPosition = Destination.Length - 1
ReDim Preserve Destination(Destination.Length + Source.Length)
Try
For i = 0 To Source.Length - 1
Destination(intCurrPosition) = Source(i)
intCurrPosition = intCurrPosition + 1
Next
Return Destination
Catch ex As Exception
End Try
End Function
The above code is keeping the first byte array and not combining the
second byte array even though there are no errors.
Any ideas?
Justin