Hi stevenbey,
Nice work. Much better.
Here's the final code for all posterity in Visual Basic and C#.
[Visual Basic]
Public Function GetNextOccurenceOfDay(ByVal value As DateTime, ByVal dayOfWeek As DayOfWeek) As DateTime
Dim daysToAdd As Integer = dayOfWeek - value.DayOfWeek
If daysToAdd < 1 Then
daysToAdd += 7
End If
Return value.AddDays(daysToAdd)
End Function
[C#]
/// <summary>
/// Gets the next occurence of future day.
/// </summary>
/// <param name="value">DateTime value to start with.</param>
/// <param name="dayOfWeek">Next Day of week to find.</param>
public DateTime GetNextOccurenceOfDay(DateTime value, DayOfWeek dayOfWeek)
{
int daysToAdd = dayOfWeek - value.DayOfWeek;
if(daysToAdd < 1)
{
daysToAdd += 7;
}
return value.AddDays(daysToAdd);
}
Thanks,
Geoffrey McGill - Product Manager
Basic Date Picker - A Quicker Picker(TM) - ASP.NET Calendar, Date and Time Web Controls