VB.NET - counting days between two dates with exclusions
问题 I'm trying to count the days between two dates, excluding Saturdays and Sundays . I've written this code so far Dim startDay As Integer Dim endDay As Integer Dim days As Integer Dim count As Integer startDay = dtpStartDate.Value.DayOfWeek endDay = dtpEndDate.Value.DayOfWeek For days = startDay To endDay If days = 0 Or days = 6 Then 'Sunday = 0, Saturday = 6 count += 1 End If Next lblNoOfDays.Text = count It works fine if you choose the two dates within the same week. (ex: 23rd Jan to 27th Jan