|
真正的公农历转换类for VB(22) ' Dim f As Long ' Dim sumDay As Long ' Dim info As Long ' sumDay = 348 ' i = &H8000 ' info = LunarInfo(y - 1900) And &H1000FFFF '屏蔽高位, ' Do ' f = info And i ' If f <> 0 Then ' sumDay = sumDay + 1 ' End If ' i = BitRight16(i, 1) ' Loop Until i < &H10 ' lYearDays = sumDay + leapDays(y) lYearDays = LunarYearDays(y - 1900) '先计算出每年的天数,并形成数组,以减少以后的运算时间 End Function '传回农历 y年m月的总天数 Private Function lMonthDays(ByVal y As Long, ByVal m As Long) As Long If (LunarInfo(y - 1900) And &H1000FFFF) And BitRight32(&H10000, m) Then lMonthDays = 30 Else lMonthDays = 29 End If End Function '传回农历 y年闰月的天数 Private Function leapDays(y As Long) As Long If leapMonth(y) Then If LunarInfo(y - 1900) And &H10000 Then leapDays = 30 Else leapDays = 29 End If Else leapDays = 0 End If End Function '传回农历 y年闰哪个月 1-12 , 没闰传回 0 Private Function leapMonth(y As Long) As Long Dim i As Long i = LunarInfo(y - 1900) And &HF If i > 12 Then Debug.Print y End If leapMonth = i End Function '计算公历年月的天数 Private Function SolarDays(y As Long, m As Long) As Long Dim d As Long If (y Mod 4) = 0 Then '闰年 If m = 2 Then d = 29
|