Solved

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

Posted on 2004-09-11
2
168 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
Comment Utility
For ci = 0 To ListBox2.Items.Count - 1

should fix it.
0
 
LVL 1

Author Comment

by:drcyrus3d
Comment Utility
That was the problem. Thanx a lot.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Custom auto number 6 51
Change data in datatable 8 15
VB.Net - CSV to Oracle table 4 27
Unable  to create new object 9 19
This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

744 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

17 Experts available now in Live!

Get 1:1 Help Now