Solved

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

Posted on 2004-09-11
2
169 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

911 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

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now