導航:首頁 > 編程語言 > 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編程判斷平年閏年相關的資料

熱點內容
修改本地賬戶管理員文件夾 瀏覽:416
python爬蟲工程師招聘 瀏覽:283
小鵬p7聽音樂哪個app好 瀏覽:354
linux下的防火牆 瀏覽:954
凌達壓縮機美芝壓縮機 瀏覽:350
php後面代碼不執行 瀏覽:236
微我手機怎樣設置應用加密 瀏覽:202
條件加密 瀏覽:628
androidstudio設置中文 瀏覽:641
汽車換壓縮機能提升製冷 瀏覽:628
安卓開發配什麼電腦 瀏覽:607
linux下php模塊 瀏覽:78
阿里雲伺服器終端在哪裡 瀏覽:147
app紙有什麼用 瀏覽:224
cuteftp命令 瀏覽:507
最開始的編程語言是什麼 瀏覽:759
at遠程命令 瀏覽:492
雲伺服器哪家好點 瀏覽:215
android系統源碼閱讀 瀏覽:931
dumpjava分析工具 瀏覽:680