Search code examples
.netvb.netdatetimepicker

Setting a date/time to a date time picker in .net 1.1


I have a datetime picker in one of our apps. When loading up the win form I need the date time picker to default to the Wednesday following todays date. Any idea how to do this? We are using .Net 1.1 for this app.

Thanks, Mike


Solution

  • this should do it...just add days until you hit the next wednesday

    Public Function GetNextDayOfWeek(ByVal dow As DayOfWeek) As DateTime
           Dim d = DateTime.Now.AddDays(1)
           While d.DayOfWeek <> dow
               d = d.AddDays(1)
           End While
    
           Return d
       End Function