Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
Private Sub Command1_Click()
Dim test(0 To 3) As Byte
Dim i As Long, j As Long
i = 1000
'从long转化为byte数组
CopyMemory test(0), i, 4
'从byte数组转化为long
CopyMemory j, test(0), 4
MsgBox j
End Sub
或者根据下面的代码中的函数进行转换:
Public Function HiByte(ByVal wParam As Integer) As Byte
'note: VB4-32 users should declare this function As Integer
HiByte = (wParam And &HFF00&) / (&H100)
End Function
Public Function LoByte(ByVal wParam As Integer) As Byte
'note: VB4-32 users should declare this function As Integer
LoByte = wParam And &HFF&
End Function
Public Function HiWord(wParam As Long) As Integer
If wParam And &H80000000 Then