VB6.0怎样把2个16BIT数据转为1个32BIT数据
各位前辈请教一下VB6中怎样把2两个16Bit数据转为1个32Bit数据?如下图所示
D11534,D11535为两个16Bit数据,值分别为-30168和1
上图为合成一个32Bit数据,值变为100904.
请教给位大哥怎样用VB6.0写出来啊??
[解决办法]
纯VB实现:
Private Type DBIT16
h As Integer
l As Integer
End Type
Private Type BIT32
data As Long
End Type
Private Sub Command1_Click()
Dim d As BIT32, t As DBIT16
t.h = -30168
t.l = 1
LSet d = t
Debug.Print d.data
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 h As Integer, l As Integer, tmp(0 To 3) As Byte, d As Long
h = -30168
l = 1
CopyMemory tmp(0), h, 2
CopyMemory tmp(2), l, 2
CopyMemory d, tmp(0), 4
Debug.Print d
End Sub