LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default CheckIBAN

Dear all,

Why overflow-error on mod-function ???


Public Function CheckIBAN(ByVal strIBAN As String) As Boolean

'1. BE62510007547061
'2. 510007547061 BE62
'3. 510007547061111462
'4. De modulus 97 (remainder of div 97) 510007547061111462 /97 remainder =
1

On Error GoTo Errhandling

Dim strTemp As String
Dim strAllDigits As String
Dim strToken As String
Dim iLoop As Integer
Dim IBANtotalNum As Double
Dim iModulus As Integer

CheckIBAN = False

strTemp = Replace(strIBAN, " ", "")
strTemp = right$(strTemp, Len(strTemp) - 4) & Left$(strTemp, 4): MsgBox
strTemp
For iLoop = 1 To Len(strTemp)
strToken = UCase(Mid$(strTemp, iLoop, 1))
If Not IsNumeric(strToken) Then
If InStr(1, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", strToken) = 0 Then
Exit For
Else
strToken = CStr(Asc(strToken) - 55)
End If
End If
strAllDigits = strAllDigits & strToken
Next iLoop

MsgBox strAllDigits & " len=" & Len(strAllDigits)

IBANtotalNum = CDec(strAllDigits): MsgBox "decimal = " & IBANtotalNum
iModulus = IBANtotalNum Mod 97
If iModulus = 1 Then CheckIBAN = True

Exit Function

Errhandling:
MsgBox err.Number & " " & err.Description
End Function


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 04:22 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"