⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 module1.bas

📁 本代码为在VB6.0环境下所写的CRC_16字节型算法
💻 BAS
字号:
Attribute VB_Name = "Module1"
'由于VB不支持指针传递,因此在CRC函数中需直接调用数组
Public DataCrc(0 To 100) As Byte
Public Sub fCrc(CrcLen As Integer)
   Dim i, j As Integer
   Dim Crc As Long
   Dim BitSelect As Integer
   Dim intDataCrcIndex As Integer
   
   Crc = 0
   BitSelect = &H80
   DataCrcIndex = 0
        
   Do
        BitSelect = &H80
        For i = 0 To 7
            If (Crc And 32768) <> 0 Then
                Crc = Crc * 2
                Crc = Crc Xor &H1021
            Else
                Crc = Crc * 2
            End If
            If (DataCrc(DataCrcIndex) And BitSelect) <> 0 Then
            
                Crc = Crc Xor &H1021
       
            End If
             Crc = Crc And 65535
            BitSelect = BitSelect / 2
        Next i

        DataCrcIndex = DataCrcIndex + 1
        CrcLen = CrcLen - 1
   Loop While CrcLen <> 0
   
    Form1.Text2.Text = Hex(Crc And &HFFFF)
    
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -