为了正常的体验网站,请在浏览器设置里面开启Javascript功能!
首页 > vb编程计算阴历的计算方法[资料]

vb编程计算阴历的计算方法[资料]

2018-06-18 10页 doc 26KB 53阅读

用户头像

is_977556

暂无简介

举报
vb编程计算阴历的计算方法[资料]vb编程计算阴历的计算方法[资料] VB编程计算农历的计算方法 '下面是一个关于VB的农历算法 '日期数据定义方法如下 '前12个字节代表1-12月为大月或是小月,1为大月30天,0为小月29天, '第13位为闰月的情况,1为大月30天,0为小月29天,第14位为闰月的月 '份,如果不是闰月为0,否则给出月份,10、11、12分别用A、B、C来表 '示,即使用16进制。最后4位为当年家农历新年-即农历1月1日所在公历 '的日期,如0131代表1月31日。 'GetYLDate函数使用方式如下tYear为要输入的...
vb编程计算阴历的计算方法[资料]
vb编程计算阴历的计算[资料] VB编程计算农历的计算方法 '下面是一个关于VB的农历算法 '日期数据定义方法如下 '前12个字节代表1-12月为大月或是小月,1为大月30天,0为小月29天, '第13位为闰月的情况,1为大月30天,0为小月29天,第14位为闰月的月 '份,如果不是闰月为0,否则给出月份,10、11、12分别用A、B、C来表 '示,即使用16进制。最后4位为当年家农历新年-即农历1月1日所在公历 '的日期,如0131代表1月31日。 'GetYLDate数使用方式如下tYear为要输入的年,tMonth为月,tDay为 '日期,YLyear是返回值,返加农历的年份,如甲子年,YLShuXing返回 '的是属象,如鼠。IsGetGl是设置是不是通过农历取公历值,如果是, '前三个返回相应的公历日期,而且返回值是一个公历日期。 Function GetYLDate(tYear As Integer, tMonth As Integer, tDay As Integer, _ YLyear As String, YLShuXing As String, _ Optional IsGetGl As Boolean) As String On Error Resume Next Dim daList(1900 To 2011) As String * 18 Dim conDate As Date, setDate As Date Dim AddMonth As Integer, AddDay As Integer, AddYear As Integer, getDay As Integer Dim RunYue As Boolean If tYear , 2010 Or tYear , 1901 Then Exit Function '如果不是有效有日期,退出 '1900 to 1909 daList(1900) = "" daList(1901) = "" daList(1902) = "" daList(1903) = "" daList(1904) = "" daList(1905) = "" daList(1906) = "" daList(1907) = "" daList(1908) = "" daList(1909) = "" daList(1910) = "" daList(1911) = "" daList(1912) = "" daList(1913) = "" daList(1914) = "" daList(1915) = "" daList(1916) = "" daList(1917) = "" daList(1918) = "" daList(1919) = "" daList(1920) = "" daList(1921) = "" daList(1922) = "" daList(1923) = "" daList(1924) = "" daList(1925) = "" daList(1926) = "" daList(1927) = "" daList(1928) = "" daList(1929) = "" daList(1930) = "" daList(1931) = "" daList(1932) = "" daList(1933) = "" daList(1934) = "" daList(1935) = "" daList(1936) = "" daList(1937) = "" daList(1938) = "" daList(1939) = "" daList(1940) = "" daList(1941) = "" daList(1942) = "" daList(1943) = "" daList(1944) = "" daList(1945) = "" daList(1946) = "" daList(1947) = "" daList(1948) = "" daList(1949) = "" daList(1950) = "" daList(1951) = "" daList(1952) = "" daList(1953) = "" daList(1954) = "" daList(1955) = "" daList(1956) = "" daList(1957) = "" daList(1958) = "" daList(1959) = "" daList(1960) = "" daList(1961) = "" daList(1962) = "" daList(1963) = "" daList(1964) = "" daList(1965) = "" daList(1966) = "" daList(1967) = "" daList(1968) = "" daList(1969) = "" daList(1970) = "" daList(1971) = "" daList(1972) = "" daList(1973) = "" daList(1974) = "" daList(1975) = "" daList(1976) = "" daList(1977) = "" daList(1978) = "" daList(1979) = "" daList(1980) = "" daList(1981) = "" daList(1982) = "" daList(1983) = "" daList(1984) = "1011001001011A0202" daList(1985) = "" daList(1986) = "" daList(1987) = "" daList(1988) = "" daList(1989) = "" daList(1990) = "" daList(1991) = "" daList(1992) = "" daList(1993) = "" daList(1994) = "" daList(1995) = "" daList(1996) = "" daList(1997) = "" daList(1998) = "" daList(1999) = "" daList(2000) = "" daList(2001) = "" daList(2002) = "" daList(2003) = "" daList(2004) = "" daList(2005) = "" daList(2006) = "" daList(2007) = "" daList(2008) = "" daList(2009) = "" daList(2010) = "" daList(2011) = "" AddYear = tYear RunYue = False If IsGetGl Then AddMonth = Val(Mid(daList(AddYear), 15, 2)) AddDay = Val(Mid(daList(AddYear), 17, 2)) conDate = DateSerial(AddYear, AddMonth, AddDay) AddDay = tDay For i = 1 To tMonth - 1 AddDay = AddDay + 29 + Val(Mid(daList(tYear), i, 1)) Next i 'MsgBox DateDiff("d", conDate, Date) setDate = DateAdd("d", AddDay - 1, conDate) GetYLDate = setDate tYear = Year(setDate) tMonth = Month(setDate) tDay = Day(setDate) Exit Function End If CHUSHIHUA: AddMonth = Val(Mid(daList(AddYear), 15, 2)) AddDay = Val(Mid(daList(AddYear), 17, 2)) conDate = DateSerial(AddYear, AddMonth, AddDay) setDate = DateSerial(tYear, tMonth, tDay) getDay = DateDiff("d", conDate, setDate) If getDay < 0 Then AddYear = AddYear - 1: GoTo CHUSHIHUA ' addday = NearDay AddDay = 1: AddMonth = 1 For i = 1 To getDay AddDay = AddDay + 1 If AddDay = 30 + Mid(daList(AddYear), AddMonth, 1) Or (RunYue And AddDay = 30 + Mid(daList(AddYear), 13, 1)) Then If RunYue = False And AddMonth = Val("amp;H" amp; Mid(daList(AddYear), 14, 1)) Then RunYue = True Else RunYue = False AddMonth = AddMonth + 1 End If AddDay = 1 End If Next md$ = "初一初二初三初四初五初六初七初八初九初十十一十二十三 十四十五十六十七十八十九二十廿一廿二廿三廿四廿五廿六廿七廿八廿九三十" dd$ = Mid(md$, (AddDay - 1) * 2 + 1, 2) mm$ = Mid("正二三四五六七八九十寒腊", AddMonth, 1) + "月" YouGetDate = DateSerial(AddYear, AddMonth, AddDay) tiangan$ = "甲乙丙丁戊已庚辛壬癸" dizhi$ = "子丑寅卯辰巳午未申酉戌亥" Dim ganzhi(0 To 59) As String * 2 For i = 0 To 59 ganzhi(i) = Mid(tiangan$, (i Mod 10) + 1, 1) + Mid(dizhi$, (i Mod 12) + 1, 1) 'ff$ = ff$ + ganzhi(i) Next i 'MsgBox ff$, , Len(ff$) YLyear = ganzhi((AddYear - 4) Mod 60) shu$ = "鼠牛虎兔龙蛇马羊猴鸡狗猪" YLShuXing = Mid(shu$, ((AddYear - 4) Mod 12) + 1, 1) If RunYue Then mm$ = "闰" + mm$ GetYLDate = mm$ + dd$ End Function '下面是一个使用的例子,你需要在窗体上加上一个按扭,并命名为 Command1,然后将下列代码复制到窗体的代码中 Private Sub Command1_Click() Dim ty As Integer, tm As Integer, td As Integer, yl As String, sx As String '取公历1999年10月28日的农历日期 ty = 1999 tm = 10 td = 28 t = GetYLDate(ty, tm, td, yl, sx) MsgBox t MsgBox ty amp; "-" amp; tm amp; "-" amp; td amp; " " amp; yl amp; " " amp; sx '取1999年农历十月28的公历日期 t = GetYLDate(ty, tm, td, yl, sx, True) MsgBox t MsgBox ty amp; "-" amp; tm amp; "-" amp; td amp; " " amp; yl amp; " " amp; sx End Sub
/
本文档为【vb编程计算阴历的计算方法[资料]】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。 本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。 网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。

历史搜索

    清空历史搜索