[求助]如何将问题里VB代码功能转化为TC3.0环境下的功能?
请各位看看如何将以下VB代码功能转化为TC3.0环境下的功能? VB中Byte和Variant变量,用了CLng函数,在VB中, CLng返回long, -2,147,483,648 至 2,147,483,647,小数部分四舍五入。 TC3.0中我用unsigned char 代替VB的Byte变量 但VB中的Variant变量我不知道该如何替代,下面我目前使用long是不对的 请问该如何解决? 请各位支招啊! 先谢了!!! VB代码功能: ---------------------------------- Dim InDataBuf(0 To 14) As Byte Dim SumData As Variant ----------- ........ SumData = CLng(InDataBuf(0)) + CLng(InDataBuf(1)) + CLng(InDataBuf(2)) + CLng(InDataBuf(3)) + CLng(InDataBuf(4)) + CLng(InDataBuf(5)) + CLng(InDataBuf(6)) + CLng(InDataBuf(7)) + CLng(InDataBuf(8)) + CLng(InDataBuf(9)) + CLng(InDataBuf(10)) + CLng(InDataBuf(11)) + CLng(InDataBuf(12)) + CLng(InDataBuf(13)) + InDataBuf(14) Debug.Print ("SumData = "); SumData If (SumData And 255) = 0 Then ........... End If -------------------------------------------------------------- TC3.0环境下代码: ----------------------------------- unsigned char InDataBuf[15]; long SumData; //使用long型替代是错误的 SumData = long(InDataBuf[0])+long(InDataBuf[1])+long(InDataBuf[2])+long(InDataBuf[3])+long(InDataBuf[4])+long(InDataBuf[5])+long(InDataBuf[6])+long(InDataBuf[7])+long(InDataBuf[8])+long(InDataBuf[9])+long(InDataBuf[10])+long(InDataBuf[11])+long(InDataBuf[12])+long(InDataBuf[13])+long(InDataBuf[14]); printf("\n SumData = %ld \n ",SumData); |