- 29 -
6.12 Sample Computation of LRC
Below is the sample computation of LRC using VisualBasic6.0.
Declare the variable as shown below.
Since the unsigned variable cannot be used in VisualBasic6.0, a signed 16-bit integer variable is used for the data.
Likewise, the computation result of LRC will be placed in the signed 16-bit integer variable.
Dim LRC As Integer
Dim i, arry_count As Integer
Dim lrc_arry(128) As Integer
Next, data to be computed will be placed in lrc_arry() while the quantity of data will be placed in arry_count.
After that, the computation result will be placed in LRC by executing the following program:
For i = 0 To arry_count
LRC = (LRC + lrc_arry(i)) And &HFF
Next
LRC = ((Not LRC) + 1) And &HFF
For example, if 12H was computed as an error code, attach "1" and "2" at the end of the message.