公农历转换VB类

2016-01-29 12:31 10 1 收藏

公农历转换VB类,公农历转换VB类

【 tulaoshi.com - ASP.NET 】


网上流传很多计算公农历的源代码,很多,但是居然没有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, &H10

来源:http://www.tulaoshi.com/n/20160129/1486426.html

延伸阅读
标签: vb
笔者思考出数据库中存取图片的另一种方法,希望与爱好者们分享。 一、实现思路: 用户添加或修改图片时控制使用COMMONDIALOG的SHOWOPEN对话框,然后记录通用对话框的FILENAME到变量A,再使用APP.PATH找到到特定目录下的该图片文件,改变窗体上放置图片控件的属性即可显示。数据库中只使用一文本型字段记录下变量A,图片文件...
标签: 电脑入门
①启动Excel2010,在任意一个单元格输入下列函数:=TEXT(NOW(),"[$-130000]YYYY-M-D")。 ②该单元格立即得到一个日期,如下图所示,农历日期为六月初一。虽然在遇到闰月时,显示结果有点差强人意,如下图中,2010年2月9日的农历应是十二月二十六,但因为那年有个闰五月,就无辜多出来一个月了。不过总比编代码要快捷多了吧,而且...
标签: Web开发
代码如下: HTML HEAD TITLE农历与西历对照/TITLE META content="农历; 阳历; 月历; 节日; 时区; 节气; 八字; 干支; 生肖; gregorian solar; chinese lunar; calendar;" name=keywords META content=All name=robots META content="gregorian so...
这公共租赁住房的申请条件、分配程序按照“三审核、两公示”的原则逐步进行。 首先公共租赁住房的申请条件中最重要的是户口,公共租赁房向户口所在地社区居委会提出廉租住房保障申请,并提交《公共租赁住房申请表》、户口本及同户籍家庭成员身份证、收入情况证明材料、住房情况证明材料以及其他有关证明材料。 其次,...
  // 节日算法 请参见 《农历与西历对照、万年历》 unit CNYear; interface uses sysutils; type TCNDate = Cardinal; function DecodeGregToCNDate(dtGreg:TDateTime):TCNDate; function GetGregDateFromCN(cnYear,cnMonth,cnDay:word;bLeap:Boolean=False):TDateTime; function GregDate...

经验教程

866

收藏

54
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部