Home All Groups Group Topic Archive Search About
Author
17 May 2006 3:23 PM
Ali Chambers
Hi,

I 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

Author
17 May 2006 7:11 PM
Ahmed
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?
Author
17 May 2006 7:38 PM
Ali Chambers
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
Author
17 May 2006 8:16 PM
Ahmed
Hi,

Sorry, I couldn't figure out what the problem is. Did you try to
comment line 443?
Author
17 May 2006 11:38 PM
Dennis
Try changing the line:

Dim a, arinput() As String

to

Dim a as string
dim arinput() as string
--
Dennis in Houston


Show quoteHide quote
"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
>
>
Author
18 May 2006 12:39 PM
Ali Chambers
Thanks - I'll make some amendments

Alex