Hey all you clever people out there
I'm rather new to this and I'm using vb.net in visual studio 2005
and I want to add 20 WORKING days to the TODAY() value.
I'm able to add the days, but it also adds NON-WORKING days.
Thanx in advance
AP
Here's my code:
CODE
Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click
Dim instance As DateTime = Now()
Dim value As Double
Dim returnValue As DateTime
Dim datNewDate As DateTime = AddWorkingDays(Today, +20)
'MessageBox.Show("The last working day was " & datNewDate)
TextBox1.Text = Today
If TextBox1.Text = New Date Then
dateindev.Text = TextBox1.Text + instance.AddDays(20)
End If
returnValue = instance.AddDays(20)
dateindev.Text = returnValue
Me.dateindev.Text = returnValue.ToLongDateString
End Sub
Public Function AddWorkingDays(ByVal DateIn As DateTime, _
ByVal ShiftDate As Integer) As DateTime
' Adds the [ShiftDate] number of working days to DateIn
Dim datDate As DateTime = DateIn.AddDays(ShiftDate)
' Loop around until we get the need non-weekend day
While Weekday(datDate) = 1 Or Weekday(datDate) = 7
datDate = datDate.AddDays(IIf(ShiftDate < 0, -1, 1))
End While
Return datDate
End Function