VBA日期转换星座

2022-05-21 17:09:36   文档大全网     [ 字体: ] [ 阅读: ]

#文档大全网# 导语】以下是®文档大全网的小编为您整理的《VBA日期转换星座》,欢迎阅读!
转换,日期,星座,VBA
VBA日期转换星座》



使用说明:

本程序可在各种支持VBA语言的软件上直接使用,其中MS ExcelMS Access已成功测试。(把程序复制到VBA编程器里即可直接使用)



程序使用方法如下图:





程序:

Function XingZuo(MyDate As Date) '日期转换星座 On Error Resume Next

Dim strConstellation As Variant

strConstellation = Array("水瓶座", "双鱼座", "白羊座", "金牛座", "双子座", "巨蟹座", "狮子座", "处女座", "天枰座", "天蝎座", "射手座", "摩羯座") '水瓶座 120日~218 '双鱼座 219日~320 '白羊座 321日~419 '金牛座 420日~520 '双子座 521日~621 '巨蟹座 622日~722 '狮子座 723日~822 '处女座 823日~922 '天枰座 923日~1022 '天蝎座 1023日~1121 '射手座 1122日~1221 '摩羯座 1222日~119 If IsNull(MyDate) Or MyDate = 0 Then XingZuo = ""

ElseIf CDate("01/20/" & Year(MyDate)) <= MyDate And MyDate <= CDate("02/18/" & Year(MyDate)) Then XingZuo = strConstellation(0)

ElseIf CDate("02/19/" & Year(MyDate)) <= MyDate And MyDate <= CDate("03/20/" & Year(MyDate)) Then



-1- / -2-


XingZuo = strConstellation(1)

ElseIf CDate("03/21/" & Year(MyDate)) <= MyDate And MyDate <= CDate("04/19/" & Year(MyDate)) Then XingZuo = strConstellation(2)

ElseIf CDate("04/20/" & Year(MyDate)) <= MyDate And MyDate <= CDate("05/20/" & Year(MyDate)) Then XingZuo = strConstellation(3)

ElseIf CDate("05/21/" & Year(MyDate)) <= MyDate And MyDate <= CDate("06/21/" & Year(MyDate)) Then XingZuo = strConstellation(4)

ElseIf CDate("06/22/" & Year(MyDate)) <= MyDate And MyDate <= CDate("07/22/" & Year(MyDate)) Then XingZuo = strConstellation(5)

ElseIf CDate("07/23/" & Year(MyDate)) <= MyDate And MyDate <= CDate("08/22/" & Year(MyDate)) Then XingZuo = strConstellation(6)

ElseIf CDate("08/23/" & Year(MyDate)) <= MyDate And MyDate <= CDate("09/22/" & Year(MyDate)) Then XingZuo = strConstellation(7)

ElseIf CDate("09/23/" & Year(MyDate)) <= MyDate And MyDate <= CDate("10/22/" & Year(MyDate)) Then XingZuo = strConstellation(8)

ElseIf CDate("10/23/" & Year(MyDate)) <= MyDate And MyDate <= CDate("11/21/" & Year(MyDate)) Then XingZuo = strConstellation(9)

ElseIf CDate("11/22/" & Year(MyDate)) <= MyDate And MyDate <= CDate("12/21/" & Year(MyDate)) Then XingZuo = strConstellation(10)

ElseIf CDate("12/22/" & Year(MyDate)) <= MyDate Or (MyDate >= CDate("01/1/" & Year(MyDate)) And MyDate <= CDate("01/19/" & Year(MyDate))) Then XingZuo = strConstellation(11) End If

End Function

-2- / -2-


本文来源:https://www.wddqxz.cn/26a402d6195f312b3169a5bc.html

相关推荐