打印

[求助] 求助达人一个编程基础问题

0
' 定义对称日的函数  
Function IsSymmetric(ByVal dateValue As Date) As Boolean  
    ' 判断日期是否为对称日  
    If DateSerial(Year(dateValue), 1, 1) + DateSerial(Year(dateValue), 2, (Month(dateValue) - 1)) - DateSerial(Year(dateValue), Month(dateValue), 1) + DateSerial(Year(dateValue), Month(dateValue), 2) = dateValue Then  
        IsSymmetric = True  
    Else  
        IsSymmetric = False  
    End If  
End Function  
  
' 循环遍历所有日期并输出对称日  
Sub 测试()
Dim i As Integer  
For i = 1000 To 9999  
    If IsSymmetric(i) Then  
        Debug.Print i  
    End If  
Next i
End Sub
直接将以上代码复制粘贴,然后运行

[ 本帖最后由 zhenght123 于 2023-7-30 11:09(GMT+8) 编辑 ]

TOP

当前时区 GMT+8, 现在时间是 2025-3-10 20:32