title: VB6 how to get C-like integer overflow
body: <p>I want to port <a href="https://stackoverflow.com/a/7666577/481061">this simple hash algorithm</a> to VB6.</p>
  
  <p>I have come up with:</p>
  
  <pre><code>Public Function simpleHash(hashString As String) As Long
  Dim hash As Long
  Dim c As Long
  Dim i As Integer
  
      On Local Error Resume Next
  
      hash = 5381
      For i = 1 To Len(hashString)
          c = AscW(Mid$(hashString, i, 1))
          hash = hash * 33 + c
      Next i
  
      simpleHash = hash
  End Function
  </code></pre>
  
  <p>The problem is, despite my <code>On Error</code> statement which suppresses the <em>Error 6: Overflow</em> exceptions, the variable <code>hash</code> is not updated any more if an overflow occurs.</p>
  
  <p>How can I fix that or implement this algorithm differently?</p>