Question

I have the following VB.NET code:

Dim tomorrow = Now.Date.AddDays(1)
Dim weekdayname = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(tomorrow.DayOfWeek)
If weekdayname = "Thursday" Then
  something(happens)
Else
  something(happens)
End If

This doesn't appear to work, i.e. its Thursday today and I want the first thing to happen but it ignores that and goes to the second.

Was it helpful?

Solution

You say it's thursday today, but your code uses not today but tomorrow=Date.Now.AddDays(1).

Instead of the day-name which depends on the current culture, i would use the DayOfWeek-enum:

Dim today = Date.Today
If today.DayOfWeek = DayOfWeek.Thursday Then
    something(happens) 
Else
    something(happens)
End If
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top