vb 利用copymemory合并两个数组

2009-06-19 13:45

vb 利用copymemory合并两个数组

Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal length As Long)

Private Sub Form_Load()
Dim a() As Byte
Dim b() As Byte
Dim c() As Byte
a = "01234567891sss"
b = "01234567890"

'更多代码:http://hi.baidu.com/cspcool/
jionbyte a, b, c '原数组a 末端加上b生成新数组c
Debug.Print c
For i = 0 To UBound(c)
Debug.Print Chr(c(i))
Next

End Sub

Public Function jionbyte(b() As Byte, a() As Byte, c() As Byte)
cb = UBound(b) '保存原数组大小
ReDim Preserve b(UBound(b) + UBound(a) + 1) '重新定义新数组
Call CopyMemory(b(cb + 1), a(0), UBound(a) + 1) '将a数组加到b数组上
c = b '生成新数组
End Function

'http://hi.baidu.com/cspcool/item/c6b8b8bdd86325a3eaba932e

'http://extjs2.iteye.com/blog/313045

'http://www.cnblogs.com/xw885/articles/105264.html

你可能感兴趣的:(vb 利用copymemory合并两个数组)