VB 长整型和字节数组的转换问题 (Long<>Byte)
Posted by JiaJia 17 March,2009
(0)Comment
用到的API声明:
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any,Source As Any,ByVal Length As Long)
Long2Byte
Dim TempLng As Long
Dim TempBytes( 0 To 3 ) As Byte
TempLng = 2000
#If 方法1 Then
CopyMemory TempBytes( 0 ),TempLng, 4
#ElseIf 方法2 Then
TempBytes( 0 ) = TempLng And &HFF
TempBytes( 1 ) = (TempLng And &HFF00 &) / &H100
TempBytes( 2 ) = (TempLng And &HFF0000 ) / &H10000
TempBytes( 3 ) = (TempLng And &H7F000000 ) / &H1000000 Or (((TempLng And &H80000000 ) <> 0 ) And &H80 )
#End If
Byte2Long
原文链接:https://www.f2er.com/vb/262148.htmlDim l_byte( 0 To 3 ) As Byte '要被转化的Byte()
Dim l_long As Long '要保存转化的Long
l_byte( 0 ) = & 1F
l_byte( 1 ) = & 2F
l_byte( 2 ) = & 3F
l_byte( 3 ) = & 4F
l_long = "&H" & ( CStr (Hex(l_byte( 0 ))) & CStr (Hex(l_byte( 1 )))) & CStr (Hex(l_byte( 2 ))) & CStr (Hex(l_byte( 3 )))