|
-
April 21st, 2010, 06:41 PM
#1
array of any month's all date
Hello readers,
i need to populate all date for an specific month selected by the user from a combo box where i added all months name. can any one let me know that how i can create array of any months of the year, very new coder in vb.Net. hope you will guide me. plz.. plz...plz....
regards
-
April 22nd, 2010, 03:08 AM
#2
Re: array of any month's all date
Something like this :
Code:
Public Class Form1
Dim dtSel As Date = DateTime.Now
Dim NumDays As Integer
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
NumDays = dtSel.DaysInMonth(DateTime.Now.Year, ComboBox1.SelectedIndex + 1)
ComboBox2.Items.Clear()
For i As Integer = 1 To NumDays
ComboBox2.Items.Add(i)
Next
End Sub
End Class
Just add 2 ComboBoxes to the form. The trick is in the Date object's DaysInMonth method, which uses the curent year, as well as the current month's selection. Why I said +1, is because arrays start at 0 and there is no month zero
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|