Solved

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

Posted on 2009-07-03
4
357 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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
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…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

743 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

10 Experts available now in Live!

Get 1:1 Help Now