Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with storing numbers in an array

Status
Not open for further replies.

needhelpso

Programmer
Feb 14, 2004
11
0
0
US
Hi all again,
Here is the code that works:
Dim elements() As String = New String() {"1", "2", "3"}
Dim i As Integer
For i = 0 To ubound(elements)
Me.dropdownlist2.Items.Add(New ListItem(elements(i)))
Next

However, instead of New String() {"1", "2", "3"} how can I add the numbers 1 through 52? Instead of listing all 52 numbers out?

Any help will be great.
 
You could just create a for loop and increment the counter by one, and use that to initialise the arrya. i.e.

Code:
Dim counter as integer

for int counter = 1 to 52
    me.dropdownlist2.items.add(new ListItem(counter.ToString))
next counter

James :)

James Culshaw
james@miniaturereview.co.uk
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top