+ Reply to Thread
Results 1 to 2 of 2

Creating a check digit

  1. #1
    Patrick
    Guest

    Creating a check digit

    Hey guys, I need you help, creating a check digit.

    I have a number: 012Q
    Base sequence:
    0123456789BCDFGHJKLMNPQRSTVWXYZ
    I need to return the positions of each char:
    0 1 2 22

    Then something like: =MOD('0'+'1'+'2'+'22',31)+1
    That will result in: 26

    The end value I need returned is T as T is at position 26

    Your help is much appreciated.


  2. #2
    Tom Ogilvy
    Guest

    Re: Creating a check digit

    Sub AAA()
    sStr = "0123456789BCDFGHJKLMNPQRSTVWXYZ"
    ReDim arr(0 To Len(sStr) - 1)
    For i = 1 To Len(sStr)
    arr(i - 1) = Mid(sStr, i, 1)
    Next

    sStr1 = "012Q"
    For i = 1 To Len(sStr1)
    res = Application.Match(Mid(sStr1, i, 1), _
    arr, 0)
    If Not IsError(res) Then
    lSum = lSum + res - 1
    Else
    MsgBox "Bad code"
    Exit Sub
    End If
    Next
    res = lSum Mod 31
    MsgBox arr(res) & " " & lSum
    End Sub

    lSum is actually 25, but that gives the 26th element of the array ("T")
    since it is zero based.

    --
    Regards,
    Tom Ogilvy


    "Patrick" <[email protected]> wrote in message
    news:[email protected]...
    > Hey guys, I need you help, creating a check digit.
    >
    > I have a number: 012Q
    > Base sequence:
    > 0123456789BCDFGHJKLMNPQRSTVWXYZ
    > I need to return the positions of each char:
    > 0 1 2 22
    >
    > Then something like: =MOD('0'+'1'+'2'+'22',31)+1
    > That will result in: 26
    >
    > The end value I need returned is T as T is at position 26
    >
    > Your help is much appreciated.
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1