imports System
imports System.Diagnostics
Imports Microsoft.VisualBasic
Class EquationScript
Inherits FcProcFuncSetEQ
Function evaluate() As Long
Dim pCode as String
If Context._OBJECTSYMBOL = "ITEM" Then
pCode = ObjProperty("KeyCode")
Else
If Context._OBJECTSYMBOL = "FORMULA" Then
pCode = ObjProperty("ItemCode")
End If
End If
Dim pLen as Integer = pCode.Length
If pLen = 5 Then
Dim coCode as String = tparam("Company Code")
Dim cLen as Integer = coCode.Length
If cLen = 6 Then
Dim sccCode as String = "10" & coCode & pCode
Dim i, oddSum, evenSum as Integer
For i = 0 to sccCode.Length - 1
If i Mod 2 = 0 Then
evenSum = evenSum + CInt(sccCode.Substring(i, 1))
Else
oddSum = oddSum + CInt(sccCode.Substring(i, 1))
End If
Next i
oddSum = oddSum * 3
Dim codeSum as Integer = oddSum + evenSum
Dim checkDigit as Integer = Math.Ceiling(codeSum / 10) * 10
checkDigit = checkDigit - codeSum
context.ReturnValue = sccCode & checkDigit
return 1
End If
End If
End Function
End Class