I have almost converted the boyer moore algorithum to vb.net but get the out of range exception in this code:
Public Function [Get](ByVal Key As Char) As Integer()
Dim HashedKey As Integer = 256
If Items(HashedKey) IsNot Nothing Then
If Items(HashedKey)(0).Key = Key Then
Return Items(HashedKey)(0).Shifts
End If
For i As Integer = 1 To Items(HashedKey).Length - 1
If Items(HashedKey)(i).Key = Key Then
Return Items(HashedKey)(i).Shifts
End If
Next i
End If
Return Nothing
I have tried to use the try catch ex as index out of range exception and it seems that the table textbox tries to then work but no match is found in the richtextbox1 area.
This is the stack trace of the exception:
at BMSearch.BMHashTable.Get(Char Key) in C:\Users\Admin\Desktop\VB Turbo Boyer Moor\BMHashTable.vb:line 26
at BMSearch.BMHashTable.Add(Char Key, Int32[] Value) in C:\Users\Admin\Desktop\VB Turbo Boyer Moor\BMHashTable.vb:line 43
at BMSearch.BMSearcher..ctor(String Pattern) in C:\Users\Admin\Desktop\VB Turbo Boyer Moor\BMSearcher.vb:line 21
at BMSearch.CIBMSearcher..ctor(String Pattern, Boolean CaseSensitive) in C:\Users\Admin\Desktop\VB Turbo Boyer Moor\CIBMSearcher.vb:line 5
at BMSearch.WinForm.button1_Click(Object sender, EventArgs e) in C:\Users\Admin\Desktop\VB Turbo Boyer Moor\WinForm.vb:line 138
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at BMSearch.WinForm.Main() in C:\Users\Admin\Desktop\VB Turbo Boyer Moor\WinForm.vb:line 134
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
Thank you in advance for the help :)