0

Hello,
I'm new here so sorry if this question isn't worded how they usually are but I can't figure out how to get vb to only display the dates of working days (Monday - Friday). I have got it to calculate days between certain dates (I thought that might get me somewhere but it hasn't).
I want 5 labels to say the day of the week the what the date is so for example;
Monday; 30th Dec.
Tuesday; 31st Dec.
Wednesday; 1st Jan.
Thursday; 2nd Jan.
Friday; 3rd Jan.
I'd want this then to repeat week after week but don't know where to start.
Thanks in advance - any guidance would be great!
From,
Luke

2
Contributors
1
Reply
11
Views
3 Years
Discussion Span
Last Post by Reverend Jim
1

Start with this

Dim sdate As Date = CDate("2014-01-01")
Dim edate As Date = CDate("2014-01-31")

Do While sdate <= edate
    If IsWeekDay(sdate) Then
        ListBox1.Items.Add(sdate & " " & WeekdayName(Weekday(sdate)))
    End If
    sdate = DateAdd(DateInterval.Day, 1, sdate)
Loop

Private Function IsWeekDay(d As Date) As Boolean
    Return d.DayOfWeek >= DayOfWeek.Monday And
           d.DayOfWeek <= DayOfWeek.Friday
End Function

This shows how to determine if a date falls between Monday and Friday.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.