General discussion

Locked

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
Next

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

***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,
Steve

This conversation is currently closed to new comments.

3 total posts (Page 1 of 1)  
| 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

John,

I thank you for the quick answer.

Steve

Collapse -

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

This question was closed by the author

Back to Web Development Forum
3 total posts (Page 1 of 1)  

Related Discussions

Related Forums