ranjith2523
Board Regular
- Joined
- Apr 29, 2014
- Messages
- 137
- Office Version
- 365
Hi Experts,
In the below Sub test2() code if I input "Hash ("acdegilmn")" then I am getting the output message as "909832457685751".
What input I should give if I need to get the output value as "945901726134069". I tried changing the input value multiple times but I am not getting the output value as "945901726134069".
Can someone help me to get the output value "945901726134069" by changing the input value in Sub test2() code ?
In the below Sub test2() code if I input "Hash ("acdegilmn")" then I am getting the output message as "909832457685751".
What input I should give if I need to get the output value as "945901726134069". I tried changing the input value multiple times but I am not getting the output value as "945901726134069".
Can someone help me to get the output value "945901726134069" by changing the input value in Sub test2() code ?
VBA Code:
Sub Hash(inputString)
Dim outputNumber As Double
outputNumber = 7
Dim letters As String
letters = "acdegilmnoprstuw"
Dim index As Long
index = 0
Dim lengthOfInputString As Double
lengthOfInputString = Len(inputString)
While (index < lengthOfInputString)
outputNumber = (outputNumber * 37 + InStr(letters, Mid(inputString, (index + 1))) - 1)
index = index + 1
Wend
MsgBox (outputNumber)
End Sub
VBA Code:
Sub test2()
Hash ("acdegilmn")
End Sub