• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 178
  • Last Modified:

I get an error when i try to add new item to a listbox.

Hy

This is a part from my code:

For ci = 0 To ListBox2.Items.Count
                If TextBox7.Text = ListBox2.Items.Item(ci) Then
                    GoTo Same_ID
                End If
            Next
            ListBox2.Items.Add(TextBox7.Text)

when it arrives at :            ListBox2.Items.Add(TextBox7.Text)

it gives me this error:

An unhandled exception of type 'System.ArgumentOutOfRangeException' occurred in system.windows.forms.dll
Additional information: Specified argument was out of the range of valid values.

What should i do??
0
drcyrus3d
Asked:
drcyrus3d
1 Solution
 
gregoryyoungCommented:
For ci = 0 To ListBox2.Items.Count - 1

should fix it.
0
 
drcyrus3dAuthor Commented:
That was the problem. Thanx a lot.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now