Spoiler

Public Function AddWorkDays(D As Date, X As Integer) As Date 'X represents number of work days only to add or subtract Dim workDaysCounter As Integer Dim returnDate As Date = D Dim daysAddend As Integer = If(X < 0, -1, 1) Do Until workDaysCounter = X returnDate = returnDate.AddDays(daysAddend) If Not (returnDate.DayOfWeek = DayOfWeek.Saturday Or returnDate.DayOfWeek = DayOfWeek.Sunday) Then workDaysCounter += daysAddend End If Loop 'for X = 0 on week day If returnDate.DayOfWeek = DayOfWeek.Saturday Then returnDate = returnDate.AddDays(2) If returnDate.DayOfWeek = DayOfWeek.Sunday Then returnDate = returnDate.AddDays(1) Return returnDate End Function

This post has been edited by **lucky3**: 05 May 2013 - 02:37 AM