Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 36 lines (32 sloc) 1.0 kB
4a5fe67 @neroanelli First Commit
authored
1 Attribute VB_Name = "PublicMod"
2 Public OpenFlag As Boolean
3 Public ConnectFlag As Boolean
4 Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
5 Public Function Hexn(ByVal number As Long, ByVal n As Integer) As String
6 Dim str As String
7
8 str = String(n, "0") + Hex(number)
9 str = Right(str, n)
10 Hexn = str
11 End Function
12
13
14 Function Crc_16(ByVal Str1 As String) As Long
15 Dim i As Integer
16 Dim j As Integer
17 Dim CVal As Long
18 Dim Temp1 As Integer
19 Dim Const1 As Long
20 CVal = 65535 '&HFFFF
21 Const1 = 40961 '&HA001
22 For i = 1 To LenB(Str1)
23 Temp1 = AscB(MidB(Str1, i, 1))
24 CVal = Temp1 Xor CVal
25 For j = 0 To 7
26 If (CVal Mod 2) = 0 Then
27 CVal = CVal \ 2
28 Else
29 CVal = CVal \ 2
30 CVal = CVal Xor Const1
31 End If
32 Next j
33 Next i
34 Crc_16 = CVal And &HFFFF&
35 End Function
Something went wrong with that request. Please try again.