CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: arrays

  1. #1
    Join Date
    Sep 2001
    Location
    South Dakota
    Posts
    20

    arrays

    Can anyone tell me exactly what this function does?

    Dim intLCV As Long
    Dim intResult As Long
    Static Multiply As Variant

    'routing number check digit calculation.
    'Returns true if checkdigit is valid, false if
    'not.

    Multiply = Array(0, 3, 7, 1, 3, 7, 1, 3, 7)

    If Len(strRNum) = 9 And IsNumeric(strRNum) Then
    For intLCV = 1 To 8
    intResult = intResult + (Multiply(intLCV) * CInt(Mid(strRNum, intLCV, 1)))
    Next intLCV
    If (10 - (intResult Mod 10)) Mod 10 = CInt(Right(strRNum, 1)) Then
    CheckDigit = True
    Else
    CheckDigit = False
    End If
    Else
    CheckDigit = False
    End If


  2. #2
    Join Date
    Sep 2001
    Location
    Québec, Canada
    Posts
    1,923

    Re: arrays

    It seems to be some sort of Credit Number validation.

    The loop (1 to 8) generates a number by multiplying each number enter in a textbox (strRNum) by a number in the array in this order (3,7,1,3,7,1,3,7)

    Example, you enter 111 111 112 as the number (without spaces)
    The result will be (3*1)+(7*1)+(1*1)..., so 32

    Then, we makes a sort of validation. We divides the results by 10 taking the rest, this rest must be the last number enter in the textbox (strRNum)

    In my example, 32 Mod 10 gives 2, 2 is my last number (# 9), so it is valid

    I did not try it, but it appears to be that


    CodeGuru VB FAQ Visual Basic Frequently Asked Questions
    VB Code color Tool to color your VB code on CodeGuru
    Before you post Importants informations to know before posting

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured