我正在尝试将一些Java代码转换为Excel,但所需的哈希码函数生成了溢出错误,而不是包装到负数。
Function FnGetStringHashCode(ByVal str As String) As Integer
Dim result, i
FnGetStringHashCode = 17
For i = 1 To Len(str)
Dim c, a
c = Mid(str, i, 1)
a = AscW(c)
FnGetStringHashCode = 31 * FnGetStringHashCode + a
Next i
End Function
有没有在Excel VBA中实现这一点的方法?