Solved

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

Posted on 2009-07-03
4
360 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

Question has a verified solution.

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

Suggested Solutions

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
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…

756 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