C
cui5555
Unregistered / Unconfirmed
GUEST, unregistred user!
下面是VB关于计算检查和的函数,请给变为D7 代码,
Public Function ProcessOutputString(outputString As String) As String
Dim i As Integer
Dim CSb1 As Integer
Dim CSb2 As Integer
Dim CSb3 As Integer
Dim CSb$
Dim X
X = 0
For i = 1 To (Len(outputString)) 'Starting with the CMD character
X = X + Asc(Mid(outputString, i, 1)) 'adds ascii values together
Next i
CSb1 = 256 - X
CSb2 = 127 And (CSb1) 'Twos Complement
CSb3 = 64 Or (CSb2) 'OR 0x40
CSb$ = Chr(Val("&H"
&
(Hex(CSb3))))
ProcessOutputString = Chr(2) &
outputString &
CSb$ &
Chr(3)
End Function
Public Function ProcessOutputString(outputString As String) As String
Dim i As Integer
Dim CSb1 As Integer
Dim CSb2 As Integer
Dim CSb3 As Integer
Dim CSb$
Dim X
X = 0
For i = 1 To (Len(outputString)) 'Starting with the CMD character
X = X + Asc(Mid(outputString, i, 1)) 'adds ascii values together
Next i
CSb1 = 256 - X
CSb2 = 127 And (CSb1) 'Twos Complement
CSb3 = 64 Or (CSb2) 'OR 0x40
CSb$ = Chr(Val("&H"
&
(Hex(CSb3))))
ProcessOutputString = Chr(2) &
outputString &
CSb$ &
Chr(3)
End Function