Please refer below code
C#
public DateTime Next(DateTime from, DayOfWeek dayOfWeek)
{
int start = (int)from.DayOfWeek;
int target = (int)dayOfWeek;
if (target <= start)
target += 7;
return from.AddDays(target - start);
}
Or
var date = DateTime.Now;
var nextSunday = date.AddDays(7 - (int)date.DayOfWeek);
VB
Public Function [Next](from As DateTime, dayOfWeek As DayOfWeek) As DateTime
Dim start As Integer = CInt(from.DayOfWeek)
Dim target As Integer = CInt(dayOfWeek)
If target <= start Then
target += 7
End If
Return from.AddDays(target - start)
End Function
Or
Dim [date] = DateTime.Now
Dim nextSunday = [date].AddDays(7 - CInt([date].DayOfWeek))
I hope this will help you out.