[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

CheckSum calculation ... ATTN Dave Zug



Dave (and others),

I used the VB code that you posted earlier as base for calculating the checksum. 
 I believe that there might be a problem with it.  Let me know what you 
think.  But, in order to calculate the checksum appropriately I had to use 
the following code....

Private CalculateCSUM() as String
     Dim lngCSUM As Long
     Dim byteCurrentByte As Byte
     Dim lngCursorPos As Long
   
     lngCSUM = 0
     byteCurrentByte = 0
   
     For lngCursorPos = 9 To (m_lngBINFileSize)
          Get m_intBINFileNum, lngCursorPos, byteCurrentByte
          lngCSUM = lngCSUM + byteCurrentByte   
     Next
   
     lngCSUM = lngCSUM Mod 65536

     CalculateCSUM = Hex(lngCSUM)
End Function

I removed the error checking code and the progress control code to simplify 
it.  m_lngBINFileSize is the current file size.  m_intBINFileNum is the 
current file number.  You had originally posted the end of the loop to be 
(FileSize - 9).  However, this does not seem to work.  It could be me ;-
)  What do you think?  However, when using my code on BINs with valid CSUMs 
the function returns the valid CSUM as stored in the BIN.  When using this 
function on BINs with invalid CSUMs the returned Valid CSUM is the same 
as what other CSUM calculators return.  

Tim