Web Development

General discussion


VB code snippet - what does it do?

By stevef199 ·
***BEGIN CODE SNIPPET***************************
For i = 0 To 9
a = Mid(acc, i + 1, 1)
arr(i) = a
If (i < 9) Then
m = arr(i) * (i + 1)
s = s + m
End If

r = s Mod 10
If r <> arr(9) Then
MsgBox " Wrong format ", vbCritical

***END CODE SNIPPET******************************

What is this VB code supposed to be doing?

acc is a string that is 13 characters long;
here is a sample: 9999999999-99

Many thanks in advance,

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Comments

Collapse -

by john.a.wills In reply to VB code snippet - what do ...

s becomes the sum of each value before the hyphen multiplied by its position (starting with 1) in the string. I imagine the intention is to calculate a check digit or digit pair, perhaps to occupy, or be tested against, the positions after the hyphen.

Collapse -

by stevef199 In reply to


I thank you for the quick answer.


Collapse -

by stevef199 In reply to VB code snippet - what do ...

This question was closed by the author

Related Discussions

Related Forums