以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  这段代码我如何修改到狐表使用  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=73825)

--  作者:blackzhu
--  发布时间:2015/8/27 15:22:00
--  这段代码我如何修改到狐表使用
  1. <%
  2. \'Wonsoft, Welcome to visit my web http://wonsoft.cn
  3. \'***********************************************
  4. \' 类名称:ChinaDay
  5. \' 用途:
  6. \' 根据输入的日期计算该日期的农历天干地支及当年属相
  7. \' 使用方法:
  8. \' 第一个参数为输入参数,不填写默认为当日,
  9. \' 只计算1921-2-8之后的日期
  10. \' ##-------------------------------------------##
  11. \' Dim objChinaDay 
  12. \' Dim sDay, sWeekDay, sChinaDay, sChinaYear,sChinaAni
  13. \' Set objChinaDay = New ChinaDay
  14. \' Call objChinaDay.Action("",sDay,sWeekDay,sChinaYear,sChinaDay,sChinaAni)
  15. \' Response.Write sDay&"<BR>"
  16. \' Response.Write sWeekDay&"<BR>"
  17. \' Response.Write sChinaYear&"<BR>"
  18. \' Response.Write sChinaDay&"<BR>"
  19. \' Response.Write sChinaAni&"<BR>"
  20. \' ##-------------------------------------------##
  21. \' Copyright: 本代码非原创,是2001年收集的,原作者未知。
  22. \' License:Free
  23. \'*******************************************************
  24. Class ChinaDay
  25. Dim arrWeekName(7), MonthAdd(11), NongliData(99)
  26. Dim arrTianGan(9), arrDiZhi(11), arrShuXiang(11), arrDayName(30), arrMonName(12)
  27. Dim curTime, curYear, curMonth, curDay, curWeekday
  28. Dim i, m, n, k, isEnd, bit, TheDate
  29. \'初始化数据
  30. Sub Class_Initialize()
  31. \'---------------------------------------------------
  32. \'定义显示字串
  33. \'星期名
  34. arrWeekName(0) = "*"
  35. arrWeekName(1) = "星期日"
  36. arrWeekName(2) = "星期一"
  37. arrWeekName(3) = "星期二"
  38. arrWeekName(4) = "星期三"
  39. arrWeekName(5) = "星期四"
  40. arrWeekName(6) = "星期五"
  41. arrWeekName(7) = "星期六"
  42. \'天干名称
  43. arrTianGan(0) = "甲"
  44. arrTianGan(1) = "乙"
  45. arrTianGan(2) = "丙"
  46. arrTianGan(3) = "丁"
  47. arrTianGan(4) = "戊"
  48. arrTianGan(5) = "己"
  49. arrTianGan(6) = "庚"
  50. arrTianGan(7) = "辛"
  51. arrTianGan(8) = "壬"
  52. arrTianGan(9) = "癸"
  53. \'地支名称
  54. arrDiZhi(0) = "子"
  55. arrDiZhi(1) = "丑"
  56. arrDiZhi(2) = "寅"
  57. arrDiZhi(3) = "卯"
  58. arrDiZhi(4) = "辰"
  59. arrDiZhi(5) = "巳"
  60. arrDiZhi(6) = "午"
  61. arrDiZhi(7) = "未"
  62. arrDiZhi(8) = "申"
  63. arrDiZhi(9) = "酉"
  64. arrDiZhi(10) = "戌"
  65. arrDiZhi(11) = "亥"
  66. \'属相名称
  67. arrShuXiang(0) = "鼠"
  68. arrShuXiang(1) = "牛"
  69. arrShuXiang(2) = "虎"
  70. arrShuXiang(3) = "兔"
  71. arrShuXiang(4) = "龙"
  72. arrShuXiang(5) = "蛇"
  73. arrShuXiang(6) = "马"
  74. arrShuXiang(7) = "羊"
  75. arrShuXiang(8) = "猴"
  76. arrShuXiang(9) = "鸡"
  77. arrShuXiang(10) = "狗"
  78. arrShuXiang(11) = "猪"
  79. \'农历日期名
  80. arrDayName(0) = "*"
  81. arrDayName(1) = "初一"
  82. arrDayName(2) = "初二"
  83. arrDayName(3) = "初三"
  84. arrDayName(4) = "初四"
  85. arrDayName(5) = "初五"
  86. arrDayName(6) = "初六"
  87. arrDayName(7) = "初七"
  88. arrDayName(8) = "初八"
  89. arrDayName(9) = "初九"
  90. arrDayName(10) = "初十"
  91. arrDayName(11) = "十一"
  92. arrDayName(12) = "十二"
  93. arrDayName(13) = "十三"
  94. arrDayName(14) = "十四"
  95. arrDayName(15) = "十五"
  96. arrDayName(16) = "十六"
  97. arrDayName(17) = "十七"
  98. arrDayName(18) = "十八"
  99. arrDayName(19) = "十九"
  100. arrDayName(20) = "二十"
  101. arrDayName(21) = "廿一"
  102. arrDayName(22) = "廿二"
  103. arrDayName(23) = "廿三"
  104. arrDayName(24) = "廿四"
  105. arrDayName(25) = "廿五"
  106. arrDayName(26) = "廿六"
  107. arrDayName(27) = "廿七"
  108. arrDayName(28) = "廿八"
  109. arrDayName(29) = "廿九"
  110. arrDayName(30) = "三十"
  111. \'农历月份名
  112. arrMonName(0) = "*"
  113. arrMonName(1) = "正"
  114. arrMonName(2) = "二"
  115. arrMonName(3) = "三"
  116. arrMonName(4) = "四"
  117. arrMonName(5) = "五"
  118. arrMonName(6) = "六"
  119. arrMonName(7) = "七"
  120. arrMonName(8) = "八"
  121. arrMonName(9) = "九"
  122. arrMonName(10) = "十"
  123. arrMonName(11) = "十一"
  124. arrMonName(12) = "腊"
  125. \'---------------------------------------------------------
  126. \'公差数据定义
  127. \'公历每月前面的天数
  128. MonthAdd(0) = 0
  129. MonthAdd(1) = 31
  130. MonthAdd(2) = 59
  131. MonthAdd(3) = 90
  132. MonthAdd(4) = 120
  133. MonthAdd(5) = 151
  134. MonthAdd(6) = 181
  135. MonthAdd(7) = 212
  136. MonthAdd(8) = 243
  137. MonthAdd(9) = 273
  138. MonthAdd(10) = 304
  139. MonthAdd(11) = 334
  140. \'农历数据
  141. NongliData(0) = 2635
  142. NongliData(1) = 333387
  143. NongliData(2) = 1701
  144. NongliData(3) = 1748
  145. NongliData(4) = 267701
  146. NongliData(5) = 694
  147. NongliData(6) = 2391
  148. NongliData(7) = 133423
  149. NongliData(8) = 1175
  150. NongliData(9) = 396438
  151. NongliData(10) = 3402
  152. NongliData(11) = 3749
  153. NongliData(12) = 331177
  154. NongliData(13) = 1453
  155. NongliData(14) = 694
  156. NongliData(15) = 201326
  157. NongliData(16) = 2350
  158. NongliData(17) = 465197
  159. NongliData(18) = 3221
  160. NongliData(19) = 3402
  161. NongliData(20) = 400202
  162. NongliData(21) = 2901
  163. NongliData(22) = 1386
  164. NongliData(23) = 267611
  165. NongliData(24) = 605
  166. NongliData(25) = 2349
  167. NongliData(26) = 137515
  168. NongliData(27) = 2709
  169. NongliData(28) = 464533
  170. NongliData(29) = 1738
  171. NongliData(30) = 2901
  172. NongliData(31) = 330421
  173. NongliData(32) = 1242
  174. NongliData(33) = 2651
  175. NongliData(34) = 199255
  176. NongliData(35) = 1323
  177. NongliData(36) = 529706
  178. NongliData(37) = 3733
  179. NongliData(38) = 1706
  180. NongliData(39) = 398762
  181. NongliData(40) = 2741
  182. NongliData(41) = 1206
  183. NongliData(42) = 267438
  184. NongliData(43) = 2647
  185. NongliData(44) = 1318
  186. NongliData(45) = 204070
  187. NongliData(46) = 3477
  188. NongliData(47) = 461653
  189. NongliData(48) = 1386
  190. NongliData(49) = 2413
  191. NongliData(50) = 330077
  192. NongliData(51) = 1197
  193. NongliData(52) = 2637
  194. NongliData(53) = 268877
  195. NongliData(54) = 3365
  196. NongliData(55) = 531109
  197. NongliData(56) = 2900
  198. NongliData(57) = 2922
  199. NongliData(58) = 398042
  200. NongliData(59) = 2395
  201. NongliData(60) = 1179
  202. NongliData(61) = 267415
  203. NongliData(62) = 2635
  204. NongliData(63) = 661067
  205. NongliData(64) = 1701
  206. NongliData(65) = 1748
  207. NongliData(66) = 398772
  208. NongliData(67) = 2742
  209. NongliData(68) = 2391
  210. NongliData(69) = 330031
  211. NongliData(70) = 1175
  212. NongliData(71) = 1611
  213. NongliData(72) = 200010
  214. NongliData(73) = 3749
  215. NongliData(74) = 527717
  216. NongliData(75) = 1452
  217. NongliData(76) = 2742
  218. NongliData(77) = 332397
  219. NongliData(78) = 2350
  220. NongliData(79) = 3222
  221. NongliData(80) = 268949
  222. NongliData(81) = 3402
  223. NongliData(82) = 3493
  224. NongliData(83) = 133973
  225. NongliData(84) = 1386
  226. NongliData(85) = 464219
  227. NongliData(86) = 605
  228. NongliData(87) = 2349
  229. NongliData(88) = 334123
  230. NongliData(89) = 2709
  231. NongliData(90) = 2890
  232. NongliData(91) = 267946
  233. NongliData(92) = 2773
  234. NongliData(93) = 592565
  235. NongliData(94) = 1210
  236. NongliData(95) = 2651
  237. NongliData(96) = 395863
  238. NongliData(97) = 1323
  239. NongliData(98) = 2707
  240. NongliData(99) = 265877
  241. End Sub
  242. \'############################################################
  243. \'主要方法 Action
  244. \' inDay 输入日期,如果不输入则默认为当前日期
  245. \' sDay 中文格式日期
  246. \' sWeekDay 周几
  247. \' sChinaYear 农历年
  248. \' sChinaDay 农历日
  249. \' sChinaAni 属相
  250. \'############################################################
  251. Public Function Action(inDay,sDay,sWeekDay,sChinaYear,sChinaDay,sChinaAni)
  252. \'转换要转换的日期
  253. If inDay="" Or Not IsDate(inDay) Then
  254. \'获取当前系统时间
  255. curTime = Now()
  256. Else
  257. curTime = CDate(inDay)
  258. End If
  259. If Datediff("d",curTime,Cdate("1921-2-8"))>0 Then
  260. Exit Function
  261. End If
  262. \'生成当前公历年、月、日 ==> sDay
  263. curYear = Year(curTime)
  264. curMonth = Month(curTime)
  265. curDay = Day(curTime)
  266. sDay = curYear&"年"
  267. If (curMonth < 10) Then
  268. sDaysDay = sDay&"0"&curMonth&"月"
  269. Else
  270. sDaysDay = sDay&curMonth&"月"
  271. End If
  272. If (curDay < 10) Then
  273. sDaysDay = sDay&"0"&curDay&"日"
  274. Else
  275. sDaysDay = sDay&curDay&"日"
  276. End If 
  277. \'生成当前公历星期 ==> sWeekDay
  278. curWeekday = Weekday(curTime)
  279. sWeekDay = arrWeekName(curWeekday)
  280. \'计算到初始时间1921年2月8日的天数:1921-2-8(正月初一)
  281. TheDate = (curYear - 1921) * 365 + Int((curYear - 1921) / 4) + curDay + MonthAdd(curMonth - 1) - 38
  282. If ((curYear Mod 4) = 0 AND curMonth > 2) Then
  283. TheDateTheDate = TheDate + 1
  284. End If
  285. \'计算农历天干、地支、月、日
  286. isEnd = 0
  287. m = 0
  288. \'------------------------------------
  289. Do
  290. If (NongliData(m) < 4095) Then
  291. k = 11
  292. Else
  293. k = 12
  294. End if
  295. n = k
  296. \'------------------------------------
  297. Do
  298. If (n < 0) Then
  299. Exit Do
  300. End If
  301. \'获取NongliData(m)的第n个二进制位的值
  302. bit = NongliData(m)
  303. For i = 1 To n Step 1
  304. bit = Int(bit / 2)
  305. Next
  306. bitbit = bit Mod 2
  307. If (TheDate <= 29 + bit) Then
  308. isEnd = 1
  309. Exit Do
  310. End If
  311. TheDateTheDate = TheDate - 29 - bit
  312. nn = n - 1
  313. Loop
  314. \'------------------------------------
  315. If (isEnd = 1) Then
  316. Exit Do
  317. End If
  318. mm = m + 1
  319. Loop
  320. \'------------------------------------
  321. curYear = 1921 + m
  322. curMonth = k - n + 1
  323. curDay = TheDate
  324. If (k = 12) Then
  325. If (curMonth = (Int(NongliData(m) / 65536) + 1)) Then
  326. curMonth = 1 - curMonth
  327. ElseIf (curMonth > (Int(NongliData(m) / 65536) + 1)) Then
  328. curMonthcurMonth = curMonth - 1
  329. End if 
  330. End If
  331. \'生成农历天干、地支==> sChinaYear
  332. sChinaYear = "农历"&arrTianGan(((curYear - 4) Mod 60) Mod 10)&arrDiZhi(((curYear - 4) Mod 60) Mod 12)&"年"
  333. \'生成属相 == > sChinaAni
  334. sChinaAni = arrShuXiang(((curYear - 4) Mod 60) Mod 12)
  335. \'生成农历月、日 ==> NongliDayStr
  336. If (curMonth < 1) Then
  337. sChinaDay = "闰"&arrMonName(-1 * curMonth)
  338. Else
  339. sChinaDay = arrMonName(curMonth)
  340. End If
  341. sChinaDaysChinaDay = sChinaDay&"月"
  342. sChinaDaysChinaDay = sChinaDay & arrDayName(curDay)
  343. End Function
  344. End Class
  345. %>

--  作者:大红袍
--  发布时间:2015/8/27 15:28:00
--  

http://www.foxtable.com/bbs/dispbbs.asp?BoardID=5&ID=1980&skin=0

 


--  作者:大红袍
--  发布时间:2015/8/27 15:34:00
--  

代码要改一改

 

\'...
Dim Bar As WinForm.NavBar
Bar = e.Form.Controls("NavBar1")
Bar.SelectedIndex = 1
Dim d As Date = Date.Today()
Dim str,str1 As String
Dim y,m,d1 As Integer
y = d.year
m = d.Month
d1 = d.day
e.Form.Controls("Label1").Text = Format(d, "D")
e.Form.Controls("Label3").Text = Format(d,"dddd")
\'天干地支农历年
Dim y1 As String = d.Year
Dim Tg As String = "庚|辛|壬|癸|甲|乙|丙|丁|戊|己"
Dim Tgs() As String
Tgs = Tg.split("|")
Dim Dz As String = "申|酉|戌|亥|子|丑|寅|卯|辰|巳|午|未"
Dim Dzs() As String
Dzs = DZ.split("|")
Dim Sx As String = "猴|鸡|狗|猪|鼠|牛|虎|兔|龙|蛇|马|羊|"
Dim Sxs() As String
Sxs = Sx.split("|")
\'农历月日
Dim nl As New Lunar(Date.Today())
Dim Month As String = "|正|二|三|四|五|六|七|八|九|十|冬|腊"
Dim Months() As String
Months = Month.split("|")
if nl.LeapMonth = Nothing OrElse nl.Month < nl.LeapMonth Then
    str = Months(nl.Month)
End If
if nl.LeapMonth = nl.Month Then
    str = "闰" & Months(nl.LeapMonth)
End If
if nl.Month > nl.LeapMonth Then
    str = Months(nl.Month)
End If

Dim Multi As String = "|初一|初二|初三|初四|初五|初六|初七|初八|初九|初十|十一|十二|十三|十四|"
Multi = Multi & "十五|十六|十七|十八|十九|廿十|廿一|廿二|廿三|廿四|廿五|廿六|廿七|廿八|廿九|卅十"
Dim Values() As String
Values = Multi.split("|")
e.Form.Controls("Label4").Text = str & "月 " & Values(nl.Day)
\'二十四节气
Dim Jq As String = "|小寒|大寒|立春|雨水|惊蛰|春分|清明|谷雨|立夏|小满|芒种|夏至|小暑|大暑|立秋|处暑|白露|秋分|寒露|霜降|立冬|小雪|大雪|冬至"
Dim Jqs() As String
Jqs = Jq.split("|")
Select Case m
    Case 1
        if d1<15 Then
            str1 = int(y*0.2422+iif(y<2000,5.93,6.0055)+iif(y=1982,1,0)-iif(y=2019,1,0)-int((y-1)/4)+int((y-1)/100)-int((y-1)/400)*iif(y>0,1,0))
        Else
            str1 = int(y*0.2422+iif(y<2000,20.66,20.72)+iif(y=2082,1,0)-int((y-1)/4)+int((y-1)/100)-int((y-1)/400)*iif(y>0,1,0))
        End If
    Case 2
        if d1<15 Then
            str1 = int(1211/5000*y+(1593+20*int(y/1900)+20*int(y/1980)+20*int(y/2100)+20*int(y/2220))/365)-int((y-1)/4)+int((y-1)/100)-int((y-1)/400)+int((y-1)/3200)
        Else
            str1 = int(0.2422*y+iif(y>2000,19.32,19.28)+iif(y=2026,-1,0)+iif(y=1923,-1,0))-int((y-1)/4)+int((y-1)/100)-int((y-1)/400)*iif(y>0,1,0)
        End If
    Case 3
        if d1<15 Then
            str1 = int(0.2422*y+iif(y>1978,6.232,6.186))-int(y/4)+int(y/100)-int(y/400)*iif(y>0,1,0)
        Else
            str1 = int(y*0.2422+21.2477)-int(y/4)+int(y/100)-int(y/400)+IIF(y=2084,1,0)
        End If
    Case 4
        if d1<15 Then
            str1 = int(y*0.2422+5.41)-int(y/4)+int(y/100)-int(y/400)
        Else
            str1 = int(y*0.2422+iif(y<2000,20.708,20.7))-int(y/4)+int(y/100)-int(y/400)
        End If
    Case 5
        if d1<15 Then
            str1 = int(y*0.2422+iif(y<2000,6.138,6.12))+iif(y=1911,1,0)-int(y/4)+int(y/100)-int(y/400)
        Else
            str1 = int(y*0.2422+iif(y<2000,21.68,21.64))+iif(y=2008,1,0)-int(y/4)+int(y/100)-int(y/400)
        End If
    Case 6
        if d1<15 Then
            str1 = int(y*0.2422+iif(y<2000,6.32,6.278))+iif(y=1902,1,0)-int(y/4)+int(y/100)-int(y/400)
        Else
            str1 = int(y*0.2422+iif(y<2000,22.02,21.97))+iif(y=1928,1,0)-int(y/4)+int(y/100)-int(y/400)
        End If
    Case 7
        if d1<15 Then
            str1 = int(y*0.2422+iif(y<2000,7.748,7.708))+iif(y=1925,1,0)+iif(y=2016,1,0)-int(y/4)+int(y/100)-int(y/400)
        Else
            str1 = int(y*0.2422+iif(y<2000,23.47,23.43))+iif(y=1922,1,0)-int(y/4)+int(y/100)-int(y/400)
        End If
    Case 8
        if d1<15 Then
            str1 = int(y*0.2422+iif(y< 2000,8.17,8.1))+iif(y<2002,1,0)-int(y/4)+int(y/100)-int(y/400)
        Else
            str1 = int(y*0.2422+iif(y<2000,23.77,23.73))-int(y/4)+int(y/100)-int(y/400)
        End If
    Case 9
        if d1<15 Then
            str1 = int(y*0.2422+iif(y<2000,8.26,8.246))+iif(y=1927,1,0)-int(y/4)+int(y/100)-int(y/400)
        Else
            str1 = int(y*0.2422+23.6459)-int(y/4)+int(y/100)-int(y/400)+iif(y=1942,1,0)
        End If
    Case 10
        if d1<15 Then
            str1 = int(y*0.2422+8.918)-int(y/4)+int(y/100)-int(y/400)
        Else
            str1 = int(y*0.2422+24.038)+iif(y=2089,1,0)-int(y/4)+int(y/100)-int(y/400)
        End If
    Case 11
        if d1<15 Then
            str1 = int(y*0.2422+8.038)+iif(y=2089,1,0)-int(y/4)+int(y/100)-int(y/400)
        Else
            str1 = int(y*0.2422+iif(y<2000,22.9,22.96))+iif(y=1978,1,0)-int(y/4)+int(y/100)-int(y/400)
        End If
    Case 12
        if d1<15 Then
            str1 = int(y*0.2422+iif(y<2000,7.72,7.78))+iif(y=1954,1,0)-int(y/4)+int(y/100)-int(y/400)
        Else
            str1 = int(y*0.2422+iif(y<2000,22.48,22.54))+iif(y=1918,-1,0)+iif(y=2021,-1,0)-int(y/4)+int(y/100)-int(y/400)
        End If
End Select
if d1 = str1 Then
    e.Form.Controls("Label5").Visible = False
    e.Form.Controls("Label6").Visible = True
    e.Form.Controls("Label6").Text = Jqs(m*2-iif(d1<15,1,0))
Else
    e.Form.Controls("Label6").Visible = False
    e.Form.Controls("Label5").Visible = True
    e.Form.Controls("Label5").Text = Tgs(y1.SubString(3)) & Dzs(y1 Mod 12) & "(" & Sxs(y1 Mod 12) & ")年"
End If


--  作者:blackzhu
--  发布时间:2015/8/27 15:38:00
--  
红袍,这段我有,我只是用全局代码写了以后 执行函数没有反应  所以想问问 这段代码在狐表我应该怎么改是对的,学习一下全局的执行方法
[此贴子已经被作者于2015/8/27 15:39:16编辑过]

--  作者:大红袍
--  发布时间:2015/8/27 15:41:00
--  
以下是引用blackzhu在2015/8/27 15:38:00的发言:
这段我有

 

有就用啊。


--  作者:blackzhu
--  发布时间:2015/8/27 15:44:00
--  
我想要学习, 
  1. Public Function Action(inDay,sDay,sWeekDay,sChinaYear,sChinaDay,sChinaAni)
执行这个函数是空值

--  作者:大红袍
--  发布时间:2015/8/27 15:44:00
--  

直接把 Class ChinaDay 的代码拷贝进去。

 

调用参考 http://www.xin3721.com/Articlenet/1381.html

 


--  作者:blackzhu
--  发布时间:2015/8/27 15:59:00
--  
我这样执行有什么问题:

Dim x As new ChinaDay
Dim inDay As String = Date.today
Dim sDay As String = Format(Date.today,"yyyyMMdd")
Dim sWeekDay As String ="星期四"
Dim sChinaYear As String = "乙未年"
Dim sChinaDay As String = "十四"
Dim sChinaAni As String ="羊年"
Dim t As String 
t = x.Action(inDay,sDay,sWeekDay,sChinaYear,sChinaDay,sChinaAni)
msgbox(t)


--  作者:blackzhu
--  发布时间:2015/8/27 16:12:00
--  
例子:

 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:天干地支.foxdb





--  作者:blackzhu
--  发布时间:2015/8/27 16:31:00
--  
顶下