Solved

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

Posted on 2004-09-11
2
170 Views
Last Modified: 2012-05-05
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
Comment
Question by:drcyrus3d
2 Comments
 
LVL 37

Accepted Solution

by:
gregoryyoung earned 500 total points
ID: 12036571
For ci = 0 To ListBox2.Items.Count - 1

should fix it.
0
 
LVL 1

Author Comment

by:drcyrus3d
ID: 12039347
That was the problem. Thanx a lot.
0

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question