TOHO ELECTRONICS TTM200 User Manual
Page 29

29
6.12 Example of LRC calculations
Following is an example of calculating LRC with VisualBasic6.0.
Variables are declared as shown below.
VisualBasic6.0 cannot use code-free variables. It therefore uses code-equipped 16-bit integer
variables as data. Similarly, the LRC calculation results are entered into code-equipped 16-bit
integer variables.
Dim LRC As Integer
Dim i, arry_count As Integer
Dim lrc_arry(128) As Integer
Then enter calculable data into the 1rc_arry(), and enter the number of data items into the
arry_count. After that, run the following program to cause the calculation results to enter the LRC.
For i = 0 To arry_count
LRC = (LRC + lrc_arry(i)) And &HFF
Next
LRC = ((Not LRC) + 1) And &HFF
If the error code is calculated as 12H as an example, affix a "1" or "2" at the end of the message.