by Gehan Fernando (47 Submissions)
Category: Miscellaneous
Compatability: VB.NET
Difficulty: Unknown Difficulty
Originally Published: Sun 17th December 2006
Date Added: Mon 8th February 2021
Rating: (1 Votes)
VB.Net - Get calender Into List Box, Simple Code, Valid Up to Yr - 9999
Try
Me.Cursor = Cursors.WaitCursor
DisplayList(NumYearList.Value, CboDisplayType.SelectedIndex)
Me.Cursor = Cursors.Default
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
Me.Cursor = Cursors.Default
End Try
End Sub
Private Enum DisplayType
All = 0
WeekDaysOnly = 1
WeekEndsOnly = 2
End Enum
Private Sub DisplayList(ByVal YearValue As Integer, ByVal DisType As DisplayType)
Dim MLoop As Integer = 1
Dim DLoop As Integer = 1
Dim DaysOfMonth As Integer = 1
Dim LoopDate As Date = Now.Date
LstDisplay.Items.Clear()
For MLoop = 1 To 12
LstDisplay.Items.Add("Month Of :- " & DateAndTime.MonthName(MLoop, False))
DaysOfMonth = Date.DaysInMonth(YearValue, MLoop)
For DLoop = 1 To DaysOfMonth
LoopDate = Date.Parse(DLoop & "/" & MLoop & "/" & YearValue)
If DisTyeValue.ToString() = DisplayType.All.ToString() Then
LstDisplay.Items.Add(LoopDate + ":- " + LoopDate.DayOfWeek.ToString())
ElseIf DisTyeValue.ToString() = DisplayType.WeekDaysOnly.ToString() Then
If DayOfWeek.Saturday <> LoopDate.DayOfWeek And DayOfWeek.Sunday <> LoopDate.DayOfWeek Then
LstDisplay.Items.Add(LoopDate + ":- " + LoopDate.DayOfWeek.ToString())
End If
ElseIf DisTyeValue.ToString() = DisplayType.WeekEndsOnly.ToString() Then
If LoopDate.DayOfWeek.ToString() = "Saturday".ToString() Or LoopDate.DayOfWeek.ToString() = "Sunday".ToString() Then
LstDisplay.Items.Add(LoopDate + ":- " + LoopDate.DayOfWeek.ToString())
End If
End If
Next
LstDisplay.Items.Add("")
Next
End Sub
Private Sub CboDisplayType_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CboDisplayType.SelectedIndexChanged
If CboDisplayType.SelectedIndex = 0 Then
DisTyeValue = DisplayType.All.ToString()
ElseIf CboDisplayType.SelectedIndex = 1 Then
DisTyeValue = DisplayType.WeekDaysOnly.ToString()
ElseIf CboDisplayType.SelectedIndex = 2 Then
DisTyeValue = DisplayType.WeekEndsOnly.ToString()
End If
End Sub
Private Sub FrmDays_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
CboDisplayType.SelectedIndex = 0
End Sub
No comments have been posted about VB.Net - Get calender Into List Box, Simple Code, Valid Up to Yr - 9999. Why not be the first to post a comment about VB.Net - Get calender Into List Box, Simple Code, Valid Up to Yr - 9999.