Results 1 to 15 of 15

Thread: [RESOLVED] working with very long numbers !!!

Threaded View

  1. #11
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: working with very long numbers !!!

    Condensing down that truly awful code offered by the Central Bank of Malta...

    ... there isn't much to it.

    No long numbers at all, you just have to look up the algorithm and go, or as in this case find some working but nasty code and clean it up.
    Code:
    Function Validate_IBAN(ByVal Account As String) As Boolean
        Dim intChar As Integer
        Dim strChar As String
        
        Account = UCase$(Account)
        If Len(Account) > 4 Then Account = Mid$(Account, 5) & Left$(Account, 4)
        intChar = Len(Account)
        Do While intChar > 0
            strChar = Mid$(Account, intChar, 1)
            If strChar Like "[A-Z]" Then
                '55 = Asc("A") - 10
                Account = Left$(Account, intChar - 1) _
                       & CStr(Asc(strChar) - 55) _
                       & Mid$(Account, intChar + 1)
            End If
            intChar = intChar - 1
        Loop
        Do While Len(Account) > 5
            Account = CStr(CLng(Left$(Account, 5)) Mod 97) & Mid$(Account, 6)
        Loop
        Validate_IBAN = (CLng(Account) Mod 97) = 1
    End Function
    Seems to work against the handful of examples I found (included in the program in a dropdown ComboBox).
    Attached Files Attached Files

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