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

查看:27
本文介绍了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天全站免登陆