當艇員選拔的意外情況我在一些VB.Net代碼如下列舉:選擇案例statment使用枚舉
Private Enum DayOfWeek
Sunday = 1
Monday = 2
Tuesday = 3
Wednesday = 4
Thursday = 5
Friday = 6
Saturday = 7
End Enum
我後來有以下Select Case
聲明:
Dim weekDay As DayOfWeek
weekDay = DatePart(DateInterval.Weekday, Now)
Dim daysToAdd As Integer
Select Case weekDay
Case DayOfWeek.Saturday Or DayOfWeek.Sunday
daysToAdd = 0
Case DayOfWeek.Thursday Or DayOfWeek.Friday
daysToAdd = 4
Case Else
daysToAdd = 2
End Select
所以當我運行代碼時,weekDay
設置爲今天(星期四)的正確值(5)。但是,當它遇到Select Case
聲明時,它會一直選擇Case Else
條件而不是DayOfWeek.Thursday
條件,我似乎無法找出原因。
有沒有人看到我失蹤的一些明顯的錯誤?
你猜對了,真棒。謝謝!我會盡快接受這個答案。 –