MS Access 2010模块案例声明

时间:2017-07-13 14:10:18

标签: vba access-vba select-case

我正在尝试在MS Access 2010 for Birthday = 5/5/1958中执行以下功能,并获得返回值“unknown”而不是“Dog”。有关此CASE声明的任何帮助吗?

Public Function whichChineseZodiacSign(Birthday As Date)

Select Case whichChineseZodiacSign
Case #2/18/1958# To #2/7/1959#
    whichChineseZodiacSign = "Dog"

Case Else
    whichChineseZodiacSign = "Unknown"
End Select
End Function

谢谢!

1 个答案:

答案 0 :(得分:1)

试试这个:

Option Explicit

Public Function whichChineseZodiacSign(Birthday As Date) As String

    Select Case Birthday
    Case #2/18/1958# To #2/7/1959#
        whichChineseZodiacSign = "Dog"
    Case Else
        whichChineseZodiacSign = "Unknown"
    End Select

End Function

在您的情况下,您在Select Case中有错误的条件。