<-- Previous || Up || Next -->

Hash String Function
String Manipulations Class

Public Function HashString( _
      ByVal vValue As Variant _
    , Optional ByVal vRangePrimeNumber As Variant _
    ) As Variant

Return a hash value for the specified string.
Converts a string into a numeric identifier that is likely unique, given an appropriate value for vRangePrimeNumber.
The number returned will be between 0 (zero) and vRangePrimeNumber - 1.

Top20: This function is among our "top-twenty" most useful.
Examples:
    HashString("Hello") = 14802676
    HashString("Hello", 4093) = 83
    HashString("World") = 10825270
    HashString("World", 4093) = 1445
See also:
    HashStringFast Function
    HashTable Class
    MetaPhone Function
    Soundex Function
    PreviousPrime Function
    IsPrime Function
Summary: Given the same string (in vValue) and vRangePrimeNumber, this function will always return the same "hash" value. The number of strings with the same hash value depends upon the value of vRangePrimeNumber and the number of strings that are "hashed." If the number of (unique) strings hashed exceeds vRangePrimeNumber, then there will definitely be duplicate hash values generated.
Note: All character comparisons are Binary so, for example, HashString("H") <> HashString("h")

vValue: The string which is to be "hashed." Function returns Null if vValue is Null or cannot be fixed up to a String.

vRangePrimeNumber: Number which determines the range of values returned from the hash operation. vRangePrimeNumber defaults to 16,777,213 (a suitably large prime number) when it is missing or Null or cannot be interpreted as a number. vRangePrimeNumber should be a positive, prime number.

Returns the hash value as a double-precision floating-point number (a Double) that will be an integer.

Copyright 1996-1999 Entisoft
Entisoft Tools is a trademark of Entisoft.