954,557 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Help recreating a LUA function into a VB.NET function

So I am working on a small project. A video game uses a scripting engine called LUA so people can create their own UI modifications in game. Which is why I am also using LUA.

I am trying to convert this LUA function into a VB.NET function and...
local function StringHash(text)
local counter = 1
local len = string.len(text)
for i = 1, len, 3 do
counter = math.fmod(counter*8161, 4294967279) + -- 2^32 - 17: Prime!
(string.byte(text,i)*16776193) +
((string.byte(text,i+1) or (len-i+256))*8372226) +
((string.byte(text,i+2) or (len-i+256))*3932164)
end
return math.fmod(counter, 4294967291) -- 2^32 - 5: Prime (and different from the prime in the loop)
end

and this is what I got, however...

Private Function StringHash(ByVal s As String) As Long
        Dim counter As Integer = 1
        Dim len = s.Length
        For i As Integer = 1 To len Step 3
            counter = ((counter * 8161) Mod 4294967279) + (Asc(s.Substring(i, 1)) * 16776193) + ((Asc(s.Substring(i + 1, 1)) Or (len - i + 256)) * 8372226) + ((Asc(s.Substring(i + 2, 1)) Or (len - i + 256)) * 3932164)
        Next
        Return counter Mod 4294967291
    End Function


It does not seem to return anything. Any Suggestions?
Thanks in advance

Archades
Newbie Poster
1 post since Aug 2011
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: