''' Dihedral Group: ''' You can use this code in Excel, Access, etc. Reverse ( myArray ) Return myArray 'A more modern version of this may look something like this 'Return (From I In str.ToArray ' Select CInt(I.ToString)).Reverse.ToArray End Function End Class VB for Applications Substring ( i, 1 )) 'we could use myArray(i) = Convert.ToInt16(str(i)) - 48 '48 is from Convert.ToInt16("0"c) Next Array. Length - 1 ) As Integer For i As Integer = 0 To str. ''' ''' ''' Reversed integer array ''' Private Shared Function StringToReversedIntArray ( ByVal str As String ) As Integer () Dim myArray ( str. ToString End Function ''' ''' Converts a string to a reversed integer array. Length - 1 c = d ( c, p ((( i + 1 ) Mod 8 ), myArray ( i ))) Next i Return inv ( c ). Equals ( 0 ) End Function ''' ''' For a given number generates a Verhoeff digit ''' ''' ''' Verhoeff check digit as string ''' Append this check digit to num Public Shared Function generateVerhoeff ( ByVal num As String ) As String Dim c As Integer = 0 Dim myArray () As Integer = StringToReversedIntArray ( num ) For i As Integer = 0 To myArray. Length - 1 c = d ( c, p (( i Mod 8 ), myArray ( i ))) Next i Return c. ![]() ''' ''' ''' True if Verhoeff compliant, otherwise false ''' Make sure the check digit is the last one! Public Shared Function validateVerhoeff ( ByVal num As String ) As Boolean Dim c As Integer = 0 Dim myArray () As Integer = StringToReversedIntArray ( num ) For i As Integer = 0 To myArray. The multiplication table static int verhoeff_d = ''' ''' Validates that an entered number is Verhoeff compliant.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |