VB6中有符号整数的字节数组 [英] Byte Array to a Signed Integer in VB6

查看:214
本文介绍了VB6中有符号整数的字节数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在VB6中从字节数组转换为带符号整数时遇到麻烦.使用.NET中的BitConverter可以很简单,但是我不确定如何使用VB6. 谢谢

I am having trouble converting from a Byte Array to a Signed Integer in VB6. This would be simple to do with BitConverter in .NET but I'm not sure what to do with VB6. Thanks

推荐答案

不幸的是,没有内置函数,您需要编写一个.这是一个快速入门的示例.

Unfortunately no built in function, you need to write one. Here is a quick sample to get you started.

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

这篇关于VB6中有符号整数的字节数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆