注册 登录
编程论坛 VB6论坛

256# * BytReceived(I) + BytReceived(I + 1)

chenjl335402 发布于 2015-05-23 22:48, 406 次点击
Dim strCharacter As String   '定义字符变量
 Dim BytReceived() As Byte    '定义接收数组
 Dim I As Integer             '定义临时变量
 BytReceived() = MSComm.Input  '将输入内容赋与字节数组
 .................

strCharacter = 256# * BytReceived(I) + BytReceived(I + 1)

 .................


请问各位大侠,上面最后一句代码是啥意思?
在VB代码中,数字后面加“#”号表示什么?
3 回复
#2
renxiaoyao362015-05-24 07:39
Double数据类型
VB中声明可以用字符声明,此处为Double数据类型,即双精度浮点类型
#3
chenjl3354022015-05-24 21:57
你好,谢谢你的回复!但以下整句代码表示什么意思呢?
strCharacter = 256# * BytReceived(I) + BytReceived(I + 1)
#4
lianyicq2015-05-25 08:50
回复 楼主 chenjl335402
256后加"#",是要求256在参与运算时作为双精度数考虑。如不加,VB会自动把它作为整型数据参与计算,可能造成溢出。
strCharacter = 256# * BytReceived(I) + BytReceived(I + 1)
BytReceived(I)存放来自串口的高八位字节,BytReceived(I + 1)存放来自串口的低八位字节,
运算后得到两个字节表示的十进制数

1