dim i as long
For i = j * 256 To SectionNumbers - 1
New_Section (i)
New_Data_Desc (i)
'最后块
' If (j < Sub_Table_Num) Then
Ts_Data(i).Last_Section_Number = SectionNumbers
Ts_Data(i).Section_Number = i
' Else
' Ts_Data(i).Last_Section_Number = SectionNumbers Mod 256
' End If
'描述符长度
Ts_Soft_Desc(i).Descriptor_Length = 11 'byte
Ts_Soft_Desc(i).Last_Table_Id = Sub_Table_Num '最后的表的ID
Ts_Soft_Desc(i).Software_Size = FileLength '文件长度
Ts_Soft_Desc(i).Software_CRC = fCRC32 '文件CRC32
Ts_Data(i).TS_Descriptor = Ts_Soft_Desc(i)
'下载符长度
Ts_Data(i).Descriptor_Loop_Length = 13
'字段长度
Ts_Data(i).Section_Length = 7 + 13 + Payload_Data_Length + 4 '24byte+数据长度
Ts_Data(i).Sub_Table_ID = 0
For k = ilen To (Payload_Data_Length * (i + 1)) - 1
DoEvents
Seek #1, k + 1
Get #1, , sbyte
Ts_Data(i).Payload_Data(k - Payload_Data_Length * i) = sbyte
Next
SectionCRC i, lCRC32 '这里提示"byref参数类型不符",如何改正?
Ts_Data(i).TS_Descriptor.Software_CRC = lCRC32
ilen = ilen + Payload_Data_Length
Next
'得到Section的CRC值Public Sub SectionCRC(k As long, Optional rResult As Long) Dim myByte(0 To 3094) As Byte
myByte(0) = FristByte(Ts_Data(k).Table_Id)
myByte(1) = SecondByte(Ts_Data(k).Section_Syntax_Indicator, Ts_Data(k).Reserved_Feature_Use3, Ts_Data(k).Section_Length)
myByte(2) = ThirdByte(Ts_Data(k).Section_Length)
myByte(3) = FourthByte(Ts_Data(k).Reserved_Feature_Use11)
myByte(4) = FifthByte(Ts_Data(k).Reserved_Feature_Use11, Ts_Data(k).Sub_Table_ID)
myByte(5) = SixthByte(Ts_Data(k).Reserved_Feature_Use2, Ts_Data(k).Version_Number, Ts_Data(k).Current_Next_Indicator)
myByte(6) = SeventhByte(Ts_Data(k).Section_Number)
myByte(7) = EighthByte(Ts_Data(k).Last_Section_Number)
myByte(8) = NinthByte(Ts_Data(k).Reserved_Feature_Use4, Ts_Data(k).Descriptor_Loop_Length)
myByte(9) = TenthByte(Ts_Data(k).Descriptor_Loop_Length)
myByte(10) = Desc_1Byte(Ts_Data(k).TS_Descriptor.Descriptor_Tag)
myByte(11) = Desc_2Byte(Ts_Data(k).TS_Descriptor.Descriptor_Length)
myByte(12) = Desc_3Byte(Ts_Data(k).TS_Descriptor.Software_Version)
myByte(13) = Desc_4Byte(Ts_Data(k).TS_Descriptor.Software_Version)
myByte(14) = Desc_5Byte(Ts_Data(k).TS_Descriptor.Software_Size)
myByte(15) = Desc_6Byte(Ts_Data(k).TS_Descriptor.Software_Size)
myByte(16) = Desc_7Byte(Ts_Data(k).TS_Descriptor.Software_Size)
myByte(17) = Desc_8Byte(Ts_Data(k).TS_Descriptor.Software_Size)
myByte(18) = Desc_9Byte(Ts_Data(k).TS_Descriptor.Software_CRC)
myByte(19) = Desc_10Byte(Ts_Data(k).TS_Descriptor.Software_CRC)
myByte(20) = Desc_11Byte(Ts_Data(k).TS_Descriptor.Software_CRC)
myByte(21) = Desc_12Byte(Ts_Data(k).TS_Descriptor.Software_CRC)
myByte(22) = Desc_13Byte(Ts_Data(k).TS_Descriptor.Last_Table_Id, Ts_Data(k).TS_Descriptor.Reserved_Feature_Use3)
For j = 0 To 3071
myByte(23 + j) = Ts_Data(k).Payload_Data(j)
Next
Dim cCRC32 As New cCRC32
Dim CRC As Long
rResult = cCRC32.GetByteArrayCrc32(myByte())
End Sub
For i = j * 256 To SectionNumbers - 1
New_Section (i)
New_Data_Desc (i)
'最后块
' If (j < Sub_Table_Num) Then
Ts_Data(i).Last_Section_Number = SectionNumbers
Ts_Data(i).Section_Number = i
' Else
' Ts_Data(i).Last_Section_Number = SectionNumbers Mod 256
' End If
'描述符长度
Ts_Soft_Desc(i).Descriptor_Length = 11 'byte
Ts_Soft_Desc(i).Last_Table_Id = Sub_Table_Num '最后的表的ID
Ts_Soft_Desc(i).Software_Size = FileLength '文件长度
Ts_Soft_Desc(i).Software_CRC = fCRC32 '文件CRC32
Ts_Data(i).TS_Descriptor = Ts_Soft_Desc(i)
'下载符长度
Ts_Data(i).Descriptor_Loop_Length = 13
'字段长度
Ts_Data(i).Section_Length = 7 + 13 + Payload_Data_Length + 4 '24byte+数据长度
Ts_Data(i).Sub_Table_ID = 0
For k = ilen To (Payload_Data_Length * (i + 1)) - 1
DoEvents
Seek #1, k + 1
Get #1, , sbyte
Ts_Data(i).Payload_Data(k - Payload_Data_Length * i) = sbyte
Next
SectionCRC i, lCRC32 '这里提示"byref参数类型不符",如何改正?
Ts_Data(i).TS_Descriptor.Software_CRC = lCRC32
ilen = ilen + Payload_Data_Length
Next
'得到Section的CRC值Public Sub SectionCRC(k As long, Optional rResult As Long) Dim myByte(0 To 3094) As Byte
myByte(0) = FristByte(Ts_Data(k).Table_Id)
myByte(1) = SecondByte(Ts_Data(k).Section_Syntax_Indicator, Ts_Data(k).Reserved_Feature_Use3, Ts_Data(k).Section_Length)
myByte(2) = ThirdByte(Ts_Data(k).Section_Length)
myByte(3) = FourthByte(Ts_Data(k).Reserved_Feature_Use11)
myByte(4) = FifthByte(Ts_Data(k).Reserved_Feature_Use11, Ts_Data(k).Sub_Table_ID)
myByte(5) = SixthByte(Ts_Data(k).Reserved_Feature_Use2, Ts_Data(k).Version_Number, Ts_Data(k).Current_Next_Indicator)
myByte(6) = SeventhByte(Ts_Data(k).Section_Number)
myByte(7) = EighthByte(Ts_Data(k).Last_Section_Number)
myByte(8) = NinthByte(Ts_Data(k).Reserved_Feature_Use4, Ts_Data(k).Descriptor_Loop_Length)
myByte(9) = TenthByte(Ts_Data(k).Descriptor_Loop_Length)
myByte(10) = Desc_1Byte(Ts_Data(k).TS_Descriptor.Descriptor_Tag)
myByte(11) = Desc_2Byte(Ts_Data(k).TS_Descriptor.Descriptor_Length)
myByte(12) = Desc_3Byte(Ts_Data(k).TS_Descriptor.Software_Version)
myByte(13) = Desc_4Byte(Ts_Data(k).TS_Descriptor.Software_Version)
myByte(14) = Desc_5Byte(Ts_Data(k).TS_Descriptor.Software_Size)
myByte(15) = Desc_6Byte(Ts_Data(k).TS_Descriptor.Software_Size)
myByte(16) = Desc_7Byte(Ts_Data(k).TS_Descriptor.Software_Size)
myByte(17) = Desc_8Byte(Ts_Data(k).TS_Descriptor.Software_Size)
myByte(18) = Desc_9Byte(Ts_Data(k).TS_Descriptor.Software_CRC)
myByte(19) = Desc_10Byte(Ts_Data(k).TS_Descriptor.Software_CRC)
myByte(20) = Desc_11Byte(Ts_Data(k).TS_Descriptor.Software_CRC)
myByte(21) = Desc_12Byte(Ts_Data(k).TS_Descriptor.Software_CRC)
myByte(22) = Desc_13Byte(Ts_Data(k).TS_Descriptor.Last_Table_Id, Ts_Data(k).TS_Descriptor.Reserved_Feature_Use3)
For j = 0 To 3071
myByte(23 + j) = Ts_Data(k).Payload_Data(j)
Next
Dim cCRC32 As New cCRC32
Dim CRC As Long
rResult = cCRC32.GetByteArrayCrc32(myByte())
End Sub
Public Sub SectionCRC(k As long, Optional rResult As Long) 改为Public Sub SectionCRC(ByVal k As Long, Optional ByVal rResult As Long)
试一试
Public Sub SectionCRC(Byref k As Long, Optional Byref rResult As Long)
Public Sub SectionCRC(ByVal k As Variant, Optional ByRef rResult As Long)
Public Sub SectionCRC(Byref k As Variant, Optional Byval rResult As Long)
发现与i有关,但这个i是我的for循环变量,所以很重要,不知道咋回事
dim lCRC32 as long
dim i as long
定义在for循环外边了
奇怪哦,如有需要,可提供代码!还请帮助
如果你已经声明过这二个变量,那么这段代码看不出问题,你测试下来如果与i相关,会不会在全局变量中声明过i为其它类型?或者你按F8跟踪一下i的变化.....
myByte(1) = SecondByte(Ts_Data(k).Section_Syntax_Indicator, Ts_Data(k).Reserved_Feature_Use3, Ts_Data(k).Section_Length)
myByte(6) = SeventhByte(Ts_Data(k).Section_Number)
这里边的参数有问题呀!我真的好气
谢谢大家!!!
MsgBox Desc_2Byte(e)
MsgBox Desc_3Byte(e) '溢出
MsgBox Desc_4Byte(e)Function Desc_1Byte(k As Long) As Byte
Dim m As Byte
m = (k And &HFF000000) / 16777216
Desc_5Byte = m
End FunctionFunction Desc_2Byte(k As Long) As Byte
Dim m As Byte
m = (k And &HFF0000) / 65536
Desc_6Byte = m
End FunctionFunction Desc_3Byte(k As Long) As Byte
Dim m As Byte
m = (k And &HFF00) / 256 '此处的&HFF00因为&H0000FF00,但前边四个0加不上去,出现溢出了,有什么方法保留这几个0吗 Desc_7Byte = m
End FunctionFunction Desc_4Byte(k As Long) As Byte
Dim m As Byte
m = (k And &HFF)
Desc_8Byte = m
End Function
cCRC32.GetByteArrayCrc32(myByte())
Dim i as long
Dim lCRC32 as long
就可以了
而加了后缀的 &HFF00& 直接表示 Long 的 65280 即 &H0000FF00。
Function Desc_3Byte(k As Long) As Byte
Dim m As Byte
m = (k And &HFF00&) / 256
Desc_3Byte = m
End Function