Click here to Skip to main content
15,886,799 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
how do i list the 20 numbers in listbox without using
ListBox2.Items.AddRange(1)
ListBox2.Items.AddRange(2)
ListBox2.Items.AddRange(3)
.
.
.
.
ListBox2.Items.AddRange(20)
Posted
Updated 3-Sep-14 18:13pm
v3

1 solution

First, AddRange adds more than just one item like you have. AddRange adds a collection of items all in one call.

You're looking for Items.Add(x).

Ever hear of a loop?
VB
For i As Integer = 1 To 20
    ListBox2.Items.Add(i)
Next
 
Share this answer
 
Comments
Member 10791395 5-Sep-14 4:08am    
thanks you sir,
i heard about it , but i dont know how to do it,
Dave Kreskowiak 5-Sep-14 8:33am    
In that case, you REALLY need to get a beginners book on VB.NET and work through it. This is a very basic building block of programming and you can't afford to not understand it.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900