Hi there,
I need help please calculating the checksum of a string on Visual Basic 6!
String = "50 44 57 31 32" the checksum should be 14E but I cannot figure out a way of writing the VB6 formula.
In my code, I manipulate the string message, convert to HEX and then should calculate the CheckSum + add (i.e. not mathematical addition) to "newString"
My VB6 code:
Public Sub sendPDW()
Dim strTemp As String
Dim strTempPDWsData As String
Dim strTempPDWsData2 As String
Dim strReturn As String
Dim I As Long
Dim SendPDW As String
Dim strToHex As String
Dim hexTemp2 As String
'Declare CheckSum Variables... as Long?
...
...
PDWsData = " 12"
'STRING MANIPULATION BY REMOVING THE SPACE
strTempPDWsData = Mid$(PDWsData, 2) 'PDWsData = "12"
'COMBINE WITH COMMAND
strTempPDWsData2 = "PDW" & strTempPDWsData 'strTempPDWsData2 = "PDW12"
'STRING DATA CONVERSION TO HEX
For I = 1 To Len(strTempPDWsData2)
strTemp = Hex$(Asc(Mid$(strTempPDWsData2, I, 1)))
If Len(strTemp) = 1 Then strTemp = "0" & strTemp
strToHex = strToHex & Space$(1) & strTemp
Next I
'strToHex = " 50 44 57 31 32" & "CS"
'STRING MANIPULATION BY REMOVING THE SPACE
hexTemp2 = Mid$(strToHex, 2) 'hexTemp2 = "50 44 57 31 32 CS"
...
'CheckSum Calculation of hexTemp2 in VB6 + Replace CS with CheckSum value
'Define code here
'CheckSum value = ????
'hexTemp2 + CheckSum value = newString
'Expected newString = "50 44 57 31 32 14E"
...
SendPDW = newString
If Winsock1.State = 7 Then
Winsock1.SendData (SendPDW)
End If
End Sub
Thank you!!!