<code class="vb keyword">Function</code> <code class="vb plain">checkdigit(idWithoutCheckDigit)</code>
<code class="vb plain">ucIdWithoutCheckdigit = UCase(idWithoutCheckDigit)</code>
<code class="vb plain">total = 0</code>
<code class="vb keyword">For</code> <code class="vb plain">i = Len(ucIdWithoutCheckdigit) </code><code class="vb keyword">To</code> <code class="vb plain">1 </code><code class="vb keyword">Step</code> <code class="vb plain">\-2</code>
<code class="vb plain">digit = Asc(Mid(ucIdWithoutCheckdigit, i, 1)) - 48</code>
<code class="vb plain">total = total + (2 * digit) - Int(digit / 5) * 9</code>
<code class="vb keyword">If</code> <code class="vb plain">(i > 1) </code><code class="vb keyword">Then</code>
<code class="vb plain">digit = Asc(Mid(ucIdWithoutCheckdigit, i - 1, 1)) - 48</code>
<code class="vb plain">total = total + digit</code>
<code class="vb keyword">End</code> <code class="vb keyword">If</code>
<code class="vb keyword">Next</code> <code class="vb plain">i</code>
<code class="vb plain">total = Abs(total) + 10</code>
<code class="vb plain">checkdigit = (10 - (total </code><code class="vb keyword">Mod</code> <code class="vb plain">10)) </code><code class="vb keyword">Mod</code> <code class="vb plain">10</code>
<code class="vb keyword">End</code> <code class="vb keyword">Function</code>