Listbox problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ali Chambers

    #1

    Listbox problem

    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.C lear()

    etc..

    End Sub

    and I get the error message: "Exception System.IndexOut OfRangeExceptio n
    was thrown in debugee: Index was outside the bounds of the array."

    Why is this?

    I even try adding:

    dtlist1.Items.A dd("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

  • Ahmed

    #2
    Re: Listbox problem

    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?

    Comment

    • Ali Chambers

      #3
      Re: Listbox problem

      Hi,

      I'm using SharpDevelop 2.0 as my IDE. It's an OpenSource .NET IDE.
      Here's the full exception:

      Exception System.IndexOut OfRangeExceptio n 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()
      DebuggableCallb ack()
      System.Windows. Forms.UnsafeNat iveMethods.IMso ComponentManage r.FPushMessageL oop()
      RunMessageLoopI nner()
      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.C lear ' (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

      Comment

      • Ahmed

        #4
        Re: Listbox problem

        Hi,

        Sorry, I couldn't figure out what the problem is. Did you try to
        comment line 443?

        Comment

        • Dennis

          #5
          Re: Listbox problem

          Try changing the line:

          Dim a, arinput() As String

          to

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


          "Ali Chambers" wrote:
          [color=blue]
          > Hi,
          >
          > I'm using SharpDevelop 2.0 as my IDE. It's an OpenSource .NET IDE.
          > Here's the full exception:
          >
          > Exception System.IndexOut OfRangeExceptio n 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()
          > DebuggableCallb ack()
          > System.Windows. Forms.UnsafeNat iveMethods.IMso ComponentManage r.FPushMessageL oop()
          > RunMessageLoopI nner()
          > 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.C lear ' (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
          >
          >[/color]

          Comment

          • Ali Chambers

            #6
            Re: Listbox problem

            Thanks - I'll make some amendments

            Alex

            Comment

            Working...