网上流传很多计算公农历的源代码,很多,但是居然没有vb的,晕,
所以。。。。。
用法:
以l开始的方法均为阴历,以s开始的方法均为公历
基本的两个初使函数:
linitdate:用农历年月日初使化日期对象
sinitdate: 用公历年月日初使化日期对象
其它的方法看下面的一小段代码吧
示例代码
private sub command1_click()
dim t as clsdate
dim y as long
dim m as long
dim d as long
dim st as single
dim et as single
dim da as date
dim j as long
dim ret as long
set t = new clsdate
't.sinitdate 1900, 1, 1
t.linitdate 2047, 5, 12, false '农历2047年5月12日,非闰月
debug.print t.lyear
if t.isleap = false then
debug.print t.lmonth
else
debug.print " 闰 " & t.lmonth
end if
debug.print t.cdaystr(t.lday) '农历日期中文大写
debug.print t.ganzhi(t.lyear) '求干支
debug.print t.yearattribute(t.lyear) '农历年的属相
debug.print t.syear ' 公历年
debug.print t.smonth ' 公历月
debug.print t.sday ' 公历日
debug.print t.sweekday '公历星期
debug.print t.era(t.syear)' 公历纪元
debug.print t.constellation(t.smonth, t.sday) ' 星座
debug.print "week:" & t.wholiday ' 按第几个星期几计算的假日
debug.print "solar" & t.sholiday ' 按公历计算的假日
debug.print "lunar" & t.lholiday ' 按阴历计算的假日
debug.print t.lsolarterm ' 计算节气
'以下为速度测试,很快吧。
st = timer
with t
for y = 1900 to 2049
for m = 1 to 12
for d = 1 to 28
.linitdate y, m, d, false
next
next
next
end with
't.printf
et = timer
debug.print et - st
set t = nothing
end sub
以下为代码:
option explicit
private type solarholidaystruct
month as long
day as long
recess as long
holidayname as string
end type
private type lunarholidaystruct
month as long
day as long
recess as long
holidayname as string
end type
private type weekholidaystruct
month as long
weekatmonth as long
weekday as long
holidayname as string
end type
'保持属性值的局部变量
private mvarsyear as long '局部复制
private mvarsmonth as long '局部复制
private mvarsday as long '局部复制
private mvarlyear as long '局部复制
private mvarlmonth as long '局部复制
private mvarlday as long '局部复制
private mvarisleap as boolean '局部复制
private declare function bitright32 lib "bit4vb.dll" (byval x as long, byval num as long) as long
'private declare function bitright16 lib "bit4vb.dll" (byval x as integer, byval num as integer) as integer
'定义类内部用公用变量
private solarmonth as variant
private gan as variant
private zhi as variant
private animals as variant
private solarterm as variant
private sterminfo as variant
private nstr1 as variant
private nstr2 as variant
private monthname as variant
private lunarinfo(150) as long
private lunaryeardays(150) as long
private sholidayinfo() as solarholidaystruct
private lholidayinfo() as lunarholidaystruct
private wholidayinfo() as weekholidaystruct
private mvardate as date '内部使用标准的日期变量
private sub class_initialize()
dim temparray as variant
dim i as long
dim b as long
dim sftv as variant
dim lftv as variant
dim wftv as variant
'根据vb的位计算特点,故扩充原有的数据位,将其变成32位
temparray = array( _
&h104bd8, &h104ae0, &h10a570, &h1054d5, &h10d260, &h10d950, &h116554, &h1056a0, &h109ad0, &h1055d2, _
&h104ae0, &h10a5b6, &h10a4d0, &h10d250, &h11d255, &h10b540, &h10d6a0, &h10ada2, &h1095b0, &h114977, _
&h104970, &h10a4b0, &h10b4b5, &h106a50, &h106d40, &h11ab54, &h102b60, &h109570, &h1052f2, &h104970, _
&h106566, &h10d4a0, &h10ea50, &h106e95, &h105ad0, &h102b60, &h1186e3, &h1092e0, &h11c8d7, &h10c950, _
&h10d4a0, &h11d8a6, &h10b550, &h1056a0, &h11a5b4, &h1025d0, &h1092d0, &h10d2b2, &h10a950, &h10b557, _
&h106ca0, &h10b550, &h115355, &h104da0, &h10a5d0, &h114573, &h1052d0, &h10a9a8, &h10e950, &h106aa0, _
&h10aea6, &h10ab50, &h104b60, &h10aae4, &h10a570, &h105260, &h10f263, &h10d950, &h105b57, &h1056a0, _
&h1096d0, &h104dd5, &h104ad0, &h10a4d0, &h10d4d4, &h10d250, &h10d558, &h10b540, &h10b5a0, &h1195a6, _
&h1095b0, &h1049b0, &h10a974, &h10a4b0, &h10b27a, &h106a50, &h106d40, &h10af46, &h10ab60, &h109570, _
&h104af5, &h104970, &h1064b0, &h1074a3, &h10ea50, &h106b58, &h1055c0, &h10ab60, &h1096d5, &h1092e0, _
&h10c960, &h10d954, &h10d4a0, &h10da50, &h107552, &h1056a0, &h10abb7, &h1025d0, &h1092d0, &h10cab5, _
&h10a950, &h10b4a0, &h10baa4, &h10ad50, &h1055d9, &h104ba0, &h10a5b0, &h115176, &h1052b0, &h10a930, _
&h107954, &h106aa0, &h10ad50, &h105b52, &h104b60, &h10a6e6, &h10a4e0, &h10d260, &h10ea65, &h10d530, _
&h105aa0, &h1076a3, &h1096d0, &h104bd7, &h104ad0, &h10a4d0, &h11d0b6, &h10d250, &h10d520, &h10dd45, _
&h10b5a0, &h1056d0, &h1055b2, &h1049b0, &h10a577, &h10a4b0, &h10aa50, &h11b255, &h106d20, &h10ada0)
for i = 0 to 149
lunarinfo(i) = temparray(i)
next
temparray = array( _
384, 354, 355, 383, 354, 355, 384, 354, 355, 384, _
354, 384, 354, 354, 384, 354, 355, 384, 355, 384, _
354, 354, 384, 354, 354, 385, 354, 355, 384, 354, _
383, 354, 355, 384, 355, 354, 384, 354, 384, 354, _
354, 384, 355, 354, 385, 354, 354, 384, 354, 384, _
354, 355, 384, 354, 355, 384, 354, 383, 355, 354, _
384, 355, 354, 384, 355, 353, 384, 355, 384, 354, _
355, 384, 354, 354, 384, 354, 384, 354, 355, 384, _
355, 354, 384, 354, 384, 354, 354, 384, 355, 355, _
384, 354, 354, 383, 355, 384, 354, 355, 384, 354, _
354, 384, 354, 355, 384, 354, 385, 354, 354, 384, _
354, 354, 384, 355, 384, 354, 355, 384, 354, 354, _
384, 354, 355, 384, 354, 384, 354, 354, 384, 355, _
354, 384, 355, 384, 354, 354, 384, 354, 354, 384, _
355, 355, 384, 354, 384, 354, 354, 384, 354, 355)
for i = 0 to 149
lunaryeardays(i) = temparray(i)
next
solarmonth = array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31)
gan = array("甲", "乙", "丙", "丁", "戊", "己", "庚", "辛", "壬", "癸")
zhi = array("子", "丑", "寅", "卯", "辰", "巳", "午", "未", "申", "酉", "戌", "亥")
animals = array("鼠", "牛", "虎", "兔", "龙", "蛇", "马", "羊", "猴", "鸡", "狗", "猪")
solarterm = array("小寒", "大寒", "立春", "雨水", "惊蛰", "春分", "清明", "谷雨", "立夏", "小满", "芒种", "夏至", "小暑", "大暑", "立秋", "处暑", "白露", "秋分", "寒露", "霜降", "立冬", "小雪", "大雪", "冬至")
sterminfo = array(0, 21208, 42467, 63836, 85337, 107014, 128867, 150921, 173149, 195551, 218072, 240693, 263343, 285989, 308563, 331033, 353350, 375494, 397447, 419210, 440795, 462224, 483532, 504758)
nstr1 = array("日", "一", "二", "三", "四", "五", "六", "七", "八", "九", "十")
nstr2 = array("初", "十", "廿", "卅", " ")
monthname = array("jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec")
'国历节日 *表示放假日
sftv = array( _
1, 1, 1, "元旦", _
2, 14, 0, "情人节", 2, 10, 0, "国际气象节", _
3, 18, 0, "妇女节", 3, 12, 0, "植树节", 3, 15, 0, "消费者权益日", _
4, 1, 0, "愚人节", _
5, 1, 1, "劳动节", 5, 4, 0, "青年节", 5, 12, 0, "护士节", 5, 31, 0, "世界无烟日", _
6, 1, 0, "儿童节", _
7, 1, 0, "建党节 香港回归纪念", _
8, 1, 0, "建军节", 8, 8, 0, "中国男子节 父亲节", _
9, 9, 0, "毛泽东逝世纪念", 9, 10, 0, "教师节", 9, 18, 0, "九·一八事变纪念日", 9, 28, 0, "孔子诞辰", _
10, 1, 0, "国庆节 国际音乐日", 10, 6, 0, "老人节", 10, 24, 0, "联合国日", _
11, 12, 0, "孙中山诞辰纪念", _
12, 1, 0, "世界艾滋病日", 12, 3, 0, "世界残疾人日", 12, 20, 0, "澳门回归纪念", 12, 24, 0, "平安夜", 12, 25, 0, "圣诞节", 12, 26, 0, "毛泽东诞辰纪念")
b = ubound(sftv) + 1
redim sholidayinfo(b / 4)
for i = 0 to (b / 4) - 1
sholidayinfo(i).month = sftv(i * 4)
sholidayinfo(i).day = sftv(i * 4 + 1)
sholidayinfo(i).recess = sftv(i * 4 + 2)
sholidayinfo(i).holidayname = sftv(i * 4 + 3)
next
'农历节日 *表示放假日
lftv = array( _
1, 1, 1, "春节", _
1, 15, 0, "元宵节", _
5, 5, 0, "端午节", _
7, 7, 0, "七夕情人节", _
7, 15, 0, "中元节 盂兰盆节", _
8, 15, 0, "中秋节", _
9, 9, 0, "重阳节", _
12, 8, 0, "腊八节", _
12, 24, 0, "小年")
'12, 31, 0, "除夕") '注意除夕需要其它方法进行计算
b = ubound(lftv) + 1
redim lholidayinfo(b / 4)
for i = 0 to (b / 4) - 1
lholidayinfo(i).month = lftv(i * 4)
lholidayinfo(i).day = lftv(i * 4 + 1)
lholidayinfo(i).recess = lftv(i * 4 + 2)
lholidayinfo(i).holidayname = lftv(i * 4 + 3)
next
'某月的第几个星期几
wftv = array( _
5, 2, 1, "国际母亲节", _
5, 3, 1, "全国助残日", _
6, 3, 1, "父亲节", _
9, 3, 3, "国际和平日", _
9, 4, 1, "国际聋人节", _
10, 1, 2, "国际住房日", _
10, 1, 4, "国际减轻自然灾害日", _
11, 4, 5, "感恩节")
b = ubound(wftv) + 1
redim wholidayinfo(b / 4)
for i = 0 to (b / 4) - 1
wholidayinfo(i).month = wftv(i * 4)
wholidayinfo(i).weekatmonth = wftv(i * 4 + 1)
wholidayinfo(i).weekday = wftv(i * 4 + 2) '1 代表星期天
wholidayinfo(i).holidayname = wftv(i * 4 + 3)
next
end sub
'/////////////////////////////////////////////////////////////////////////////////////////////////////////////
'计算农历上的节气
public property get lsolarterm() as string
'//===== 某年的第n个节气为几日(从0小寒起算)
'function sterm(y,n) {
' var offdate = new date( ( 31556925974.7*(y-1900) + sterminfo[n]*60000 ) + date.utc(1900,0,6,2,5) )
' return(offdate.getutcdate())
'//节气
' tmp1 = sterm(y, m * 2) - 1
dim basedateandtime as date
dim newdate as date
dim num as double
dim y as long
dim tempstr as string
basedateandtime = #1/6/1900 2:05:00 am#
y = mvarsyear
tempstr = ""
dim i as long
for i = 1 to 24
num = 525948.76 * (y - 1900) + sterminfo(i - 1)
newdate = dateadd("n", num, basedateandtime) '按分钟计算,之所以不按秒钟计算,是因为会溢出
if abs(datediff("d", newdate, mvardate)) = 0 then
tempstr = solarterm(i - 1)
exit for
end if
next
lsolarterm = tempstr
end property
'计算按第几周星期几计算的节日
public property get wholiday() as string
dim w as long
dim i as long
dim b as long
dim firstday as date
dim tempstr as string
b = ubound(wholidayinfo)
for i = 0 to b
if wholidayinfo(i).month = mvarsmonth then '当月份相当时
w = weekday(mvardate)
if wholidayinfo(i).weekday = w then '仅当星期几也相等时
firstday = mvarsmonth & "/" & 1 & "/" & mvarsyear '取当月第一天
if (datediff("ww", firstday, mvardate) = wholidayinfo(i).weekatmonth) then
tempstr = wholidayinfo(i).holidayname
end if
end if
end if
next
wholiday = tempstr
end property
public property get lholiday() as string
dim i as long
dim b as long
dim tempstr as string
dim oy as long
dim odate as date
dim ndate as date
tempstr = ""
b = ubound(lholidayinfo)
if mvarlmonth = 12 and (mvarlday = 29 or mvarlday = 30) then
'保
oy = mvarlyear '保存农历年数
odate = mvardate
ndate = mvardate + 1
call sinitdate(year(ndate), month(ndate), day(ndate)) '计算第二天的属性
if oy = mvarlyear - 1 then '如果农历年数增加了1
tempstr = "除夕"
call sinitdate(year(odate), month(odate), day(odate)) '恢复到今天原有数据
end if
else
for i = 0 to b
if (lholidayinfo(i).month = mvarlmonth) and _
(lholidayinfo(i).day = mvarlday) then
tempstr = lholidayinfo(i).holidayname
exit for
end if
next
end if
lholiday = tempstr
end property
'求公历节日
public property get sholiday() as string
dim i as long
dim b as long
dim tempstr as string
tempstr = ""
b = ubound(sholidayinfo)
for i = 0 to b
if (sholidayinfo(i).month = mvarsmonth) and _
(sholidayinfo(i).day = mvarsday) then
tempstr = sholidayinfo(i).holidayname
exit for
end if
next
sholiday = tempstr
end property
'是否是农历的闰月
public property get isleap() as boolean
isleap = mvarisleap
end property
public property get lday() as long
lday = mvarlday
end property
public property get lmonth() as long
lmonth = mvarlmonth
end property
public property get lyear() as long
lyear = mvarlyear
end property
public property get sweekday() as long
sweekday = weekday(mvardate)
end property
public property get sday() as long
sday = mvarsday
end property
public property get smonth() as long
smonth = mvarsmonth
end property
public property get syear() as long
syear = mvarsyear
end property
'////////////////////////////////////////////////////////////////////////////////////////////////////////
public function istoday(y as long, m as long, d as long) as boolean
if (year(date) = y) and _
(month(date) = m) and _
(day(date) = d) then
istoday = true
else
istoday = false
end if
end function
'根据年份不同计算当年属于什么朝代
public function era(y as long) as string
dim tempstr as string
if y < 1874 then
tempstr = "未知"
else
if y <= 1908 then
tempstr = "清朝光绪"
if y = 1874 then
tempstr = tempstr & "元年"
else
tempstr = tempstr & upnumber(cstr(y - 1874)) & "年"
end if
else
if y <= 1910 then
tempstr = "清朝宣统"
if y = 1909 then
tempstr = tempstr & "元年"
else
tempstr = tempstr & upnumber(cstr(y - 1909 + 1)) & "年"
end if
else
if y < 1949 then
tempstr = "中华民国"
if y = 1912 then
tempstr = tempstr & "元年"
else
tempstr = tempstr & upnumber(cstr(y - 1912 + 1)) & "年"
end if
else
tempstr = "中华人民共和国成立"
if y = 1949 then
tempstr = tempstr & "了"
else
select case y
case 2000
tempstr = "千禧年"
case else
tempstr = tempstr & upnumber(cstr(y - 1949)) & "周年"
end select
end if
end if
end if
end if
end if
era = tempstr
end function
' 传入 num 传回干支, 0=甲子
public function ganzhi(num as long) as string
dim tempstr as string
dim i as long
i = (num - 1864) mod 60 '计算干支
tempstr = gan(i mod 10) & zhi(i mod 12)
ganzhi = tempstr
end function
'计算年的属相字串
public function yearattribute(y as long) as string
yearattribute = animals((y - 1900) mod 12)
end function
'将数字汉化
public function upnumber(dxs as string) as string
'检测为空时
if trim(dxs) = "" then
upnumber = ""
exit function
end if
dim sw as integer, szup as integer, tempstr as string, dxstr as string
sw = len(trim(dxs))
dim i as integer
for i = 1 to sw
tempstr = right(trim(dxs), i)
tempstr = left(tempstr, 1)
tempstr = converts(tempstr)
select case i
case 1
if tempstr = "零" then
tempstr = ""
else
tempstr = tempstr + ""
end if
case 2
if tempstr = "零" then
tempstr = "零"
else
tempstr = tempstr + "十"
end if
case 3
if tempstr = "零" then
tempstr = "零"
else
tempstr = tempstr + "百"
end if
case 4
if tempstr = "零" then
tempstr = "零"
else
tempstr = tempstr + "千"
end if
case 5
if tempstr = "零" then
tempstr = "万"
else
tempstr = tempstr + "万"
end if
case 6
if tempstr = "零" then
tempstr = "零"
else
tempstr = tempstr + "十"
end if
case 7
if tempstr = "零" then
tempstr = "零"
else
tempstr = tempstr + "百"
end if
case 8
if tempstr = "零" then
tempstr = "零"
else
tempstr = tempstr + "千"
end if
case 9
if tempstr = "零" then
tempstr = "亿"
else
tempstr = tempstr + "亿"
end if
end select
dim tempa as string
tempa = left(trim(dxstr), 1)
if tempstr = "零" then
select case tempa
case "零"
dxstr = dxstr
case "万"
dxstr = dxstr
case "亿"
dxstr = dxstr
case else
dxstr = tempstr + dxstr
end select
else
dxstr = tempstr + dxstr
end if
next
upnumber = dxstr
end function
private function converts(numstr as string) as string
select case val(numstr)
case 0
converts = "零"
case 1
converts = "一"
case 2
converts = "二"
case 3
converts = "三"
case 4
converts = "四"
case 5
converts = "五"
case 6
converts = "六"
case 7
converts = "七"
case 8
converts = "八"
case 9
converts = "九"
end select
end function
'中文日期
public function cdaystr(d as long) as string
dim s as string
select case d
case 0
s = ""
case 10
s = "初十"
case 20
s = "二十"
case 30
s = "三十"
case else
s = nstr2(d / 10) '整数除法
s = s & nstr1(d mod 10)
end select
cdaystr = s
end function
'计算星座归属
public function constellation(m as long, d as long) as string
dim y as long
dim tempdate as date
dim constellname as string
y = 2000
tempdate = m & "/" & d & "/" & y
select case tempdate
case #3/21/2003# to #4/19/2000#
constellname = "白羊"
case #4/20/2000# to #5/20/2000#
constellname = "金牛"
case #5/21/2000# to #6/21/2000#
constellname = "双子"
case #6/22/2000# to #7/22/2000#
constellname = "巨蟹"
case #7/23/2000# to #8/22/2000#
constellname = "狮子"
case #8/23/2000# to #9/22/2000#
constellname = "处女"
case #9/23/2000# to #10/23/2000#
constellname = "天秤"
case #10/24/2000# to #11/21/2000#
constellname = "天蝎"
case #11/22/2000# to #12/21/2000#
constellname = "射手"
case #12/22/2000# to #12/31/2000#
constellname = "摩蝎"
case #1/1/2000# to #1/19/2000#
constellname = "摩蝎"
case #1/20/2000# to #2/18/2000#
constellname = "水瓶"
case #2/19/2000# to #3/20/2000#
constellname = "双鱼"
case else
constellname = ""
end select
constellation = constellname
end function
'/////////////////////////////////////////////////////////////////////////////////////////////////////////
'以下为类内部使用的一些函数
'传回农历 y年的总天数
private function lyeardays(byval y as long) as long
' dim i as long
' 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
else
d = solarmonth(m - 1)
end if
else
if m = 2 then
d = 28
else
d = solarmonth(m - 1)
end if
end if
solardays = d
end function
'//////////////////////////////////////////////////////////////////////////////////////////////////
'
'主要的函数,用公历年月日对日期对象进行初使化,在此函数内部完成对私有对象属性的设置
'
'//////////////////////////////////////////////////////////////////////////////////////////////////
public sub sinitdate(byval y as long, byval m as long, byval d as long)
dim i as long
dim leap as long
dim temp as long
dim offset as long
mvardate = m & "/" & d & "/" & y
mvarsyear = y
mvarsmonth = m
mvarsday = d
'农历日期计算部分
leap = 0
temp = 0
offset = mvardate - #1/30/1900# '计算两天的基本差距
for i = 1900 to 2049
'temp = lyeardays(i) '求当年农历年天数
offset = offset - temp
if offset < 1 then exit for
next
offset = offset + temp
mvarlyear = i
leap = leapmonth(i) '闰哪个月
mvarisleap = false
for i = 1 to 12
'闰月
if leap > 0 and i = (leap + 1) and mvarisleap = false then
mvarisleap = true
i = i - 1
temp = leapdays(mvarlyear) '计算闰月天数
else
temp = lmonthdays(mvarlyear, i) '计算非闰月天数
end if
offset = offset - temp
if offset <= 0 then exit for
next
offset = offset + temp
mvarlmonth = i
mvarlday = offset
end sub
'//////////////////////////////////////////////////////////////////////////////////////////////////
'
'主要的函数,用农历年月日对日期对象进行初使化,在此函数内部完成对私有对象属性的设置
'
'//////////////////////////////////////////////////////////////////////////////////////////////////
public sub linitdate(byval y as long, byval m as long, byval d as long, optional leapflag as boolean = false)
dim i as long
dim leap as long
dim temp as long
dim offset as long
mvarlyear = y
mvarlmonth = m
mvarlday = d
offset = 0
for i = 1900 to y - 1
temp = lunaryeardays(i - 1900) '求当年农历年天数
offset = offset + temp
next
leap = leapmonth(y) '闰哪个月
if m <> leap then
mvarisleap = false '当前日期并非闰月
else
mvarisleap = leapflag '使用用户输入的是否闰月月份
end if
if (m < leap) or (leap = 0) then '当闰月在当前日期后
for i = 1 to m - 1
temp = lmonthdays(y, i) '计算非闰月天数
offset = offset + temp
next
else '在闰月后
if mvarisleap = false then '用户要计算非闰月的月份
for i = 1 to m - 1
temp = lmonthdays(y, i) '计算非闰月天数
offset = offset + temp
next
if m > leap then
temp = leapdays(y) '计算闰月天数
offset = offset + temp
end if
else '此时只有mvarisleap=ture,
for i = 1 to m
temp = lmonthdays(y, i) '计算非闰月天数
offset = offset + temp
next
end if
end if
offset = offset + d '加上当月的天数
mvardate = dateadd("d", offset, #1/30/1900#)
mvarsyear = year(mvardate)
mvarsmonth = month(mvardate)
mvarsday = day(mvardate)
end sub
'本模块用于打印出1900-2049年 每年农历的天数,可以用于数组初使化
'public sub printf()
' dim i as long, j as long
' dim temp(10) as long
' dim base as long
' base = 1900
' for i = 1 to 15
' for j = 1 to 10
' temp(j - 1) = lyeardays((i - 1) * 10 + (j - 1) + base) '求当年农历年天数
' next
' debug.print cstr(temp(0)) & " , " & cstr(temp(1)) & " , " & cstr(temp(2)) & " , " & cstr(temp(3)) & " , " & cstr(temp(4)) & " , " & cstr(temp(5)) & " , " & cstr(temp(6)) & " , " & cstr(temp(7)) & " , " & cstr(temp(8)) & " , " & cstr(temp(9)) & " , " & " _ "
' next
'end sub