Date dropdownlist in windows form

liunx

Guest
I have these code it is working in .net(web form) but not in the .net(windows form). It gives me error on listitems.

I am trying to make a dropdownlist for day/month and year
Still trying to learn vb.



Dim now As New Date
now = Date.Today
Dim nowDay As Integer = now.Day
For i As Integer = 1 To 31
Dim item As ListItem = New ListItem(i, i)
lstDay.Items.Add(item)
If i = nowDay Then
lstDay.Items.Item(i - 1).Selected = True
End If
Next
Dim months As New ArrayList
months.Add("Januarie ")
months.Add("Februarie")
months.Add("Maart")
months.Add("April")
months.Add("Mei")
months.Add("Junie")
months.Add("Julie")
months.Add("Augustus")
months.Add("September")
months.Add("Oktober")
months.Add("November")
months.Add("Desember")
Dim nowMonth As Integer = now.Month
For i As Integer = 1 To 12
Dim item As ListItem = New ListItem(months(i - 1), i)
lstMonth.Items.Add(item)
If i = nowMonth Then
lstMonth.Items.Item(i - 1).Selected = True
End If
Next

Dim nowYear As Integer = now.Year
Dim counter As Integer = 0
For i As Integer = 2001 To 2010
counter = counter + 1
Dim item As ListItem = New ListItem(i, i)
lstYear.Items.Add(item)
If i = nowYear Then
lstYear.Items.Item(counter - 1).Selected = True
End If
Nextcould you post the error message or provide a link to it?

Oh wait, so you mean this works within an asp.net page and not in an executable ap?
 
Back
Top