access 水仙花数程序和闰年程序怎么写啊
- 培训职业
- 2025-05-04 16:04:37
Private Sub Command1_Click()
Dim n As String
Dim sum As Integer
n = InputBox("请输入一个整数")
If IsNumeric(n) = False Then
MsgBox "输入错误"
Exit Sub
End If
For i = 1 To Len(n)
sum = sum + CInt(Mid(n, i, 1)) ^ 3
Next i
If sum = CInt(n) Then
MsgBox n & "是水仙花数"
Else
MsgBox n & "不是水仙花数"
End If
End Sub
Private Sub Command2_Click()
Dim n As Integer
n = InputBox("请输入年份")
If n Mod 100 = 0 Then
If n Mod 400 = 0 Then
MsgBox n & "年是闰年"
Else
MsgBox n & "年是平年"
End If
Else
If n Mod 4 = 0 Then
MsgBox n & "年是闰年"
Else
MsgBox n & "年是平年"
End If
End If
End Sub
下一篇
怎样学新概念2
多重随机标签