以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  运行错误  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=147750)

--  作者:zyxhx
--  发布时间:2020/3/23 13:33:00
--  运行错误
打开程序后提示错误,注释SystemIdle里的代码后可以使用了,请问老师以下注释掉的代码应该怎样修改,之前一直运行正常,今天才提示错误,请老师指点。

以下为错误提示及SystemIdle中的代码:

打开程序后提示如下错误:
.NET Framework 版本:4.0.30319.42000
Foxtable 版本:2020.1.19.19
错误所在事件:SystemIdle
详细错误信息:
从字符串“2020-2-30”到类型“Date”的转换无效。

然后注释以下代码后可用:

\'static ln As New Lunar(Date.Today)
\'Dim str As String = ""
\'Dim d As Date = cdate(ln.LunarDate)
\'If d.Day <= 10 Then
    \'str = cldate(d).Substring(5).trim("日")
    \'str = str.Insert(str.Length-1, "初")
\'Else
    \'str = cldate(d).Substring(5).trim("日")
\'End If
\'statusBar.Message1 = "使用单位:" & User.Name & "      " & "今天是: " & Format(Date.Today,"yyyy-MM-dd" & "  " & format(Date.now, "HH:mm:ss") & "  农历" & str & "  " & Format(Date.Today,"dddd" ))
\'statusBar.DefaultMessage = statusBar.Message1

--  作者:有点蓝
--  发布时间:2020/3/23 15:03:00
--  
很明显的提示,2月没有30天。比较合理的转换参考:http://www.foxtable.com/bbs/dispbbs.asp?BoardID=5&ID=1980&replyID=&skin=1
--  作者:zyxhx
--  发布时间:2020/3/23 15:28:00
--  
我也知道没有2月30日,但是代码如何改较合理,我感到有点懵,还请老师指点。我就是想在下方任务栏显示农历日期。
--  作者:有点蓝
--  发布时间:2020/3/23 16:02:00
--  
看2楼链接,有注释的,把农历的代码拿出来使用即可

\'农历月日
Dim nl As New Lunar(Date.Today())
Dim Month As String = "|正|二|三|四|五|六|七|八|九|十|冬|腊"
Dim str 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 -1)
End If
If nl.LeapMonth > 0 Then
    If nl.Month > nl.LeapMonth Then
        str = Months(nl.Month -1)
    End If
End If
Dim Multi As String = "|初一|初二|初三|初四|初五|初六|初七|初八|初九|初十|十一|十二|十三|十四|"
Multi = Multi & "十五|十六|十七|十八|十九|廿十|廿一|廿二|廿三|廿四|廿五|廿六|廿七|廿八|廿九|卅十"
Dim Values() As String
Values = Multi.split("|")
msgbox( str & "月 " & Values(nl.Day))

--  作者:zyxhx
--  发布时间:2020/3/23 16:38:00
--  
好的,谢谢老师