The point of this method is to emulate Java hashCode()
.
In order for this to work the project must have arithmetic overflow allowed under:
project --> compiler options --> advanced.
Public Shared Function GetHashCodeStr(value As String) As Integer
Dim finalCode As Integer = 0
For i As Integer = 0 To value.Length - 1
Dim powerValue = (Convert.ToInt32(value(i)) * Math.Pow(31, value.Length - 1 - i))
If powerValue > Integer.MaxValue Then
Dim timesGreaterThanInt = Math.Floor(powerValue / Integer.MaxValue)
powerValue = powerValue - timesGreaterThanInt - (timesGreaterThanInt) * Integer.MaxValue
End If
finalCode += CInt(powerValue)
Next
Return finalCode
End Function