Solved

How do I insert values into a listbox on a Windows form using vb.net

Posted on 2009-07-03
4
358 Views
Last Modified: 2013-11-25
In a Windows form application, I'm collecting a beginning number and an ending number and I want to iterate through the range and insert each value into a listbox. I'm pretty new to vb.net and would appreciate any help you can provide me.
0
Comment
Question by:jcartercarter
  • 3
4 Comments
 
LVL 39

Accepted Solution

by:
abel earned 500 total points
ID: 24774403
Something like the following perhaps?

Dim startNr As Integer = 10

Dim endNr As Integer = 40
 

For i = startNr To endNr

   lstMyNumbers.Add(i.ToString())   ' though ToString is not necessary, I think '

Next

Open in new window

0
 
LVL 39

Expert Comment

by:abel
ID: 24774416
Apologies, line 5 should read:

lstMyNumbers.Items.Add(i)
0
 

Author Comment

by:jcartercarter
ID: 24774443
Your right. tostring is not neccessary and I was going to tell you 'Add' is not a member of 'System.Windows.Forms.ListBox'. Adding 'Item' was the key. Thanks for the quick response.
0
 
LVL 39

Expert Comment

by:abel
ID: 24774544
Why do you grade a B when you don't first give me a follow-up comment on why this is not completely to your satisfaction? Grading at EE is not like school, instead they follow the 10 points must principle: it's an A unless....

Please reconsider your grade if you agree, or follow-up with an explanation so that I understand where you're coming from: http://www.experts-exchange.com/help.jsp?hi=404


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

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

863 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

23 Experts available now in Live!

Get 1:1 Help Now