用API函数CopyMemory即可解决,参考代码:
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
Private Sub Command1_Click()
Dim a As Long, b(3) As Byte, i As Integer
a = Val(InputBox("Input a number:"))
CopyMemory b(0), a, 4
For i = 0 To 3
Print Hex(b(i)),
Next i
Print
End Sub
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
Private Sub Command1_Click()
Dim a As Long, b(3) As Byte, i As Integer
a = Val(InputBox("Input a number:"))
CopyMemory b(0), a, 4
For i = 0 To 3
Print Hex(b(i)),
Next i
End Sub