导航:首页 > 编程语言 > vba编程判断平年闰年

vba编程判断平年闰年

发布时间:2022-08-24 16:26:45

‘壹’ 用Excel,vba编程,键盘接收一个年份值,判断它是闰年还是平年怎么做

Subaa()
a=Sheet1.Cells(1,1)
IfaMod4=0Then
Sheet1.Cells(1,2)=366
Else
Sheet1.Cells(1,2)=365
EndIf
EndSub

整除4是否为零来判断闰年还是平年。

‘贰’ VBA闰年判断:输入一年份,判断其为闰年还是平年.

年份除以4,有余数为平年,没余数为闰年

‘叁’ 判断闰年vba

SubCommandButton1_Click()
Dimy,s
y=[a1]
If(yMod4=0OryMod400=0)AndyMod100<>0Then
s="闰年"
Else
s="平年"
EndIf
[a2]=y&"年是"&s
EndSub

‘肆’ 用VBA判断是否闰年

Sub CommandButton1_Click()
Dim y,s
y = [a1]
If (y Mod 4 = 0 Or y Mod 400 = 0) And y Mod 100 <> 0 Then
s= "闰年"
Else
s= "平年"
End If
[a2]=y &"年是"& s
End Sub

‘伍’ 写VB程序:判断一年是平年还是闰年

Dim year1,year As Integer
year1=InputBox("请输入年份","年份输入框")
If year1="" Then
Exit Sub
Else
year=Int(Abs(year1))
End If
If year Mod 4 = 0 And year Mod 100 <> 0 Or year Mod 400 = 0 Then
MsgBox Str(year) & "年是闰年"
Else
MsgBox Str(year) & "年是平年"
End If

‘陆’ VB.NET 根据年月日判断是否为闰年或者平年!

VB.NET 判断是否为闰年或者平年!

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

闰年平年(TextBox1.Text)

End Sub

Function 闰年平年(ByVal MyString As String) As String

Dim MyDate As DateTime = Convert.ToDateTime(MyString)

Dim MyInfo As String = MyDate.Year.ToString() + "年是:"

If (DateTime.IsLeapYear(MyDate.Year) = True) Then

MyInfo += "闰年。"

Else

MyInfo += "平年。"

End If

MessageBox.Show(MyInfo, "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information)

Return 1

End Function

End Class

‘柒’ VBA计算平闰年,如何修改如图的代码使得可以使n为任意数都可判断 感谢!!

Subtest()
Dimn,s
n=InputBox("请输入年份:")
If(nMod4=0OrnMod400=0)AndnMod100<>0Then
s="闰年"
Else
s="平年"
EndIf
MsgBoxn&"年是"&s
EndSub

‘捌’ VB编程,求年份是闰年还是平年。下面图中所标出的错哪了求指出和改正,谢谢。

Mod
400
以后就不需要
Mod
100
了啊!

Private
Function
查询闰年(ByVal
年份
As
Integer)
As
StringBuilder

If
(年份
Mod
400
=
0)
OrElse
(年份
Mod
100
<>
0
And
年份
Mod
4
=
0)
Then

Return
New
StringBuilder("您输入的年份
"
&
年份
&
"
是闰年。")

Else

Return
New
StringBuilder("您输入的年份
"
&
年份
&
"
不是闰年。")

End
If

End
Function
这是
.NET
的,6.0
稍改改就行了

阅读全文

与vba编程判断平年闰年相关的资料

热点内容
阿里云服务器终端在哪里 浏览:144
app纸有什么用 浏览:219
cuteftp命令 浏览:502
最开始的编程语言是什么 浏览:757
at远程命令 浏览:490
云服务器哪家好点 浏览:211
android系统源码阅读 浏览:924
dumpjava分析工具 浏览:678
怎么下载cpu源码 浏览:154
代码加密怎么取消 浏览:888
编译原理代码在哪里运行 浏览:584
解密摄影pdf 浏览:72
算法编程中级题目 浏览:250
c语言编译器毕业设计 浏览:717
医保卡申请app哪个好 浏览:945
阿里云服务器上传源码 浏览:602
营销管理科特勒pdf 浏览:696
愿望清单app哪个好 浏览:461
安卓外放声音怎么解决 浏览:195
脉脉app干什么用的 浏览:361