我无法在VB6中从字节数组转换为有符号整数。这对于.NET中的BitConverter来说很简单,但我不知道如何处理VB6。 感谢
答案 0 :(得分:2)
不幸的是没有内置功能,你需要写一个。这是一个简单的示例,可以帮助您入门。
Private Function BArrayToInt(ByRef bArray() As Byte) As Integer
Dim iReturn As Integer
Dim i As Integer
For i = 0 To UBound(bArray) - LBound(bArray)
iReturn = iReturn + bArray(i) * 2 ^ i
Next i
BArrayToInt = iReturn
End Function
答案 1 :(得分:0)
空气代码(可能会导致PC崩溃,导致恐龙袭击等)。
Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (dest As Any, _ source As Any, ByVal bytes As Long)
Dim a() As Byte
Dim n As Integer
'get the bytes somehow into a()
CopyMemory n, a(0), 2