新建From1(窗体),新建Command1(按钮CommandButton),代码:
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
Private Sub Command1_Click()
Dim strA As String, strB As String
strA = "a"
strB = "Hello 码农库MaNongKu.com"
CopyMemory strA, strB, 4
MsgBox "strA=" & strA & vbCrLf & "strB=" & strB
Dim lngA As Long, lngB As Long
lngA = 1
lngB = 1234567890
CopyMemory lngA, lngB, 4
MsgBox "lngA=" & lngA & vbCrLf & "lngB=" & lngB
End Sub
下表总结了几种常见的传参数给CopyMemory的形式: