这段代码应该启动并给我正确的变量 但无论变量“numericDay”中是什么,变量“后缀”都给了我 “TH”。我不明白为什么当“numericDay”的值发生变化时它不会改变 两者都是字符串变量。
Select Case numericDay
Case numericDay = "1" Or "21" Or "31"
suffix = "st"
Case numericDay = "2" Or "22"
suffix = "nd"
Case numericDay = "3" Or "23"
suffix = "rd"
Case Else
suffix = "th"
End Select
答案 0 :(得分:30)
您的选择不正确。请尝试以下方法:
Select Case numericDay
Case "1", "21", "31"
suffix = "st"
Case "2", "22"
suffix = "nd"
Case "3", "23"
suffix = "rd"
Case Else
suffix = "th"
End Select
供将来参考:http://www.vb6.us/tutorials/learn-if-else-and-select-statements-vb6
答案 1 :(得分:8)
根据the msdn,您应该这样写:
Select Case numericDay
Case "1", "21", "31"
suffix = "st"
Case "2", "22"
suffix = "nd"
Case "3", "23"
suffix = "rd"
Case Else
suffix = "th"
End Select
答案 2 :(得分:5)
"2" Or "22"
将按字节顺序执行,或使用2和22执行,对应于22。
答案 3 :(得分:0)
您输入的选择内容有误。尝试以下
例如:根据输入的数字显示日期。
public function day_display(day as Integer) as String
select case day
case 1: day_display = "Sunday"
case 2: day_display = "Monday"
case 3: day_display = "Tuesday"
case 4: day_display = "Wednesday"
case 5: day_display = "Thursday"
case 6: day_display = "Friday"
case 7: day_display = "Saturday"
case else: day_display = "Wrong entry."
end select
end function
day_display(1)将返回“星期日”