我是新来的,之前曾使用过该网站,以摆脱粘性大学项目 - 非常棒。
然而这次它只是一个侧面项目。
我要做的是根据a)星期几和b)一天中的时间更改标签中的文字。
它将用于显示不同的电台节目主持人在当天的不同日期和不同时间显示姓名。
这是我到目前为止所得到的,如果DayOfWeek.Sunday = False则有效但反之亦然。
If DayOfWeek.Sunday = True Then
Select
Case TimeOfDay
Case "13:00:00" To "14:00:00"
Show.Text = "The Indie Show"
End Select
End If
时钟应该工作,所以没有问题。
有什么想法吗?
感谢。
答案 0 :(得分:3)
DayOfWeek.Sunday
是一个固定值,您需要DateTime.Now
来查看当前的日期和时间。
Dim today As DateTime = DateTime.Now
If today.DayOfWeek = DayOfWeek.Sunday Then
If today.Hour = 13 OrElse (today.Hour = 14 AndAlso today.Minute = 0 AndAlso today.Second = 0) Then
Show.Text = "The Indie Show"
End If
End If
在14:00之前寻找时间要容易得多,也更常见:
If today.DayOfWeek = DayOfWeek.Sunday Then
If today.Hour = 13 Then
Show.Text = "The Indie Show"
End If
End If