|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Listbox problemI have created a listbox called "dtlist1" on my VB.NET form. I call a procedure as follows: Private Sub openfile(flname As String) dtlist1.Items.Clear() etc.. End Sub and I get the error message: "Exception System.IndexOutOfRangeException was thrown in debugee: Index was outside the bounds of the array." Why is this? I even try adding: dtlist1.Items.Add("this is the first line of the listbox") before the .Items.Clear() and it doesn't help! I then get the same error message on the .Items.Add line. Can anyone suggest? Thanks, Alex I tried your code with VS .NET 2003 and 2005. No exception was thrown.
Are you sure that piece of code is throwing the exception? There is no array in that code. Items is a collection and not array. Can you post the complete exception message? Hi,
I'm using SharpDevelop 2.0 as my IDE. It's an OpenSource .NET IDE. Here's the full exception: Exception System.IndexOutOfRangeException was thrown in debugee: Index was outside the bounds of the array. openfile() - D:\Programming\DMI and PAR tester\MA tester\MainForm.vb:443,1 Button3Click() - D:\Programming\DMI and PAR tester\MA tester\MainForm.vb:423,8 OnClick() OnClick() OnMouseUp() WmMouseUp() WndProc() WndProc() WndProc() OnMessage() WndProc() DebuggableCallback() System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop() RunMessageLoopInner() RunMessageLoop() ShowDialog() ShowDialog() Main() - D:\Programming\DMI and PAR tester\MA tester\MainForm.vb:66,4 **END** Lines 438-443 are: Private Sub openfile(flname As String) Dim i,ed,sd,j As Integer Dim a, arinput() As String dtlist1.Items.Clear ' (line 443) Lines 414-423 are: For rr = 0 To filelist1.Items.Count - 1 sb = filelist1.Items(rr) sc = instrrev(sb,".") sa = instrrev(sb,"\") fln = mid(sb,sa+1,(sc-(sa+1))) if fln<>"MA_config" then openfile (sb) Next rr Hi,
Sorry, I couldn't figure out what the problem is. Did you try to comment line 443? Try changing the line:
Dim a, arinput() As String to Dim a as string dim arinput() as string -- Show quoteHide quoteDennis in Houston "Ali Chambers" wrote: > Hi, > > I'm using SharpDevelop 2.0 as my IDE. It's an OpenSource .NET IDE. > Here's the full exception: > > Exception System.IndexOutOfRangeException was thrown in debugee: Index > was outside the bounds of the array. > > openfile() - D:\Programming\DMI and PAR tester\MA > tester\MainForm.vb:443,1 > Button3Click() - D:\Programming\DMI and PAR tester\MA > tester\MainForm.vb:423,8 > OnClick() > OnClick() > OnMouseUp() > WmMouseUp() > WndProc() > WndProc() > WndProc() > OnMessage() > WndProc() > DebuggableCallback() > System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop() > RunMessageLoopInner() > RunMessageLoop() > ShowDialog() > ShowDialog() > Main() - D:\Programming\DMI and PAR tester\MA tester\MainForm.vb:66,4 > > **END** > > Lines 438-443 are: > > Private Sub openfile(flname As String) > > Dim i,ed,sd,j As Integer > Dim a, arinput() As String > > dtlist1.Items.Clear ' (line 443) > > Lines 414-423 are: > > For rr = 0 To filelist1.Items.Count - 1 > > sb = filelist1.Items(rr) > sc = instrrev(sb,".") > sa = instrrev(sb,"\") > fln = mid(sb,sa+1,(sc-(sa+1))) > > if fln<>"MA_config" then openfile (sb) > > Next rr > >
Create DB Example - It works, but is it right?
Cannot insert explict value for identity column in table 'Employees' when IDENTITY_INSERT is set to MAPI mail Access locking and transactions How to serialize into a string ? XML From Stored Proc Web Browser & Navigating to pages with errors Referring to form objects from inside a thread pool Different versions of Office Conversion of PNG to HTML Files |
|||||||||||||||||||||||