一个简单的生肖查询算法,求高手精简优化,便可做成UDF了
;十二生肖Global $sx=[["鼠","牛","虎","兔","龙","蛇","马","羊","猴","鸡","狗","猪"],["子","丑","寅","卯","辰","巳","午","未","申","酉","戌","亥"]]
Global $nf=["1900","1901","1902","1903","1904","1905","1906","1907","1908","1909","1910","1911"]
Dim $a
$a=InputBox("输入","输入4位年份(如1999)",""," M4",15,15)
If @error=1 Then exit
Select
Case StringIsInt ($a)=0 Or $a<1900 Or $a>2103;好像超过2103会不准
MsgBox(16,"提示","输入错误或超出范围~!")
Case $a=$nf
MsgBox (64,"生肖",$a&"年生属"&$sx&$sx&"年")
Case $a=$nf
MsgBox (64,"生肖",$a&"年生属"&$sx&$sx&"年")
Case $a=$nf
MsgBox (64,"生肖",$a&"年生属"&$sx&$sx&"年")
Case $a=$nf
MsgBox (64,"生肖",$a&"年生属"&$sx&$sx&"年")
Case $a=$nf
MsgBox (64,"生肖",$a&"年生属"&$sx&$sx&"年")
Case $a=$nf
MsgBox (64,"生肖",$a&"年生属"&$sx&$sx&"年")
Case $a=$nf
MsgBox (64,"生肖",$a&"年生属"&$sx&$sx&"年")
Case $a=$nf
MsgBox (64,"生肖",$a&"年生属"&$sx&$sx&"年")
Case $a=$nf
MsgBox (64,"生肖",$a&"年生属"&$sx&$sx&"年")
Case $a=$nf
MsgBox (64,"生肖",$a&"年生属"&$sx&$sx&"年")
Case $a=$nf
MsgBox (64,"生肖",$a&"年生属"&$sx&$sx&"年")
Case $a=$nf
MsgBox (64,"生肖",$a&"年生属"&$sx&$sx&"年")
Case Mod(($a-$nf),12)=0
MsgBox (64,"生肖",$a&"年生属"&$sx&$sx&"年")
Case Mod(($a-$nf),12)=0
MsgBox (64,"生肖",$a&"年生属"&$sx&$sx&"年")
Case Mod(($a-$nf),12)=0
MsgBox (64,"生肖",$a&"年生属"&$sx&$sx&"年")
Case Mod(($a-$nf),12)=0
MsgBox (64,"生肖",$a&"年生属"&$sx&$sx&"年")
Case Mod(($a-$nf),12)=0
MsgBox (64,"生肖",$a&"年生属"&$sx&$sx&"年")
Case Mod(($a-$nf),12)=0
MsgBox (64,"生肖",$a&"年生属"&$sx&$sx&"年")
Case Mod(($a-$nf),12)=0
MsgBox (64,"生肖",$a&"年生属"&$sx&$sx&"年")
Case Mod(($a-$nf),12)=0
MsgBox (64,"生肖",$a&"年生属"&$sx&$sx&"年")
Case Mod(($a-$nf),12)=0
MsgBox (64,"生肖",$a&"年生属"&$sx&$sx&"年")
Case Mod(($a-$nf),12)=0
MsgBox (64,"生肖",$a&"年生属"&$sx&$sx&"年")
Case Mod(($a-$nf),12)=0
MsgBox (64,"生肖",$a&"年生属"&$sx&$sx&"年")
Case Mod(($a-$nf),12)=0
MsgBox (64,"生肖",$a&"年生属"&$sx&$sx&"年")
EndSelect Local $y = 2013
MsgBox(0, $y, _SX($y))
Func _SX($YEAR)
Local $iYEAR = 1900
If $YEAR < $iYEAR Then Return SetError(1)
Local $sData = '子鼠丑牛寅虎卯兔辰龙巳蛇午马未羊申猴酉鸡戌狗亥猪'
Local $aData = StringRegExp($sData, '..', 3)
Return $aData
EndFunc ;==>_SX
谢谢学习、、、、 这种问题也需要拿出来讨论么。。。。 回复 1# qq270037265
从你这代码一眼看出编码新手。。 回复 4# e10614083
多理解一下,谁没有新手过! 支持一下,多多学习哈。 谢谢学习、、、、 看看看看看看看看看看 貌似写的恨得很多的样子~~~
页:
[1]