真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

vbnet判斷閏年 web判斷閏年

輸入年份,編程判斷是否為閏年 VB.NET

Private Sub Command1_Click()

創(chuàng)新互聯(lián)主營如東網(wǎng)站建設(shè)的網(wǎng)絡(luò)公司,主營網(wǎng)站建設(shè)方案,app軟件定制開發(fā),如東h5微信平臺小程序開發(fā)搭建,如東網(wǎng)站營銷推廣歡迎如東等地區(qū)企業(yè)咨詢

Dim year As Integer, y As Integer

year = Val(InputBox("要判斷的年份是:"))

Call runnian(year, y)

If y = 1 Then

Print Str(year); Spc(2); "鍵卜年是閏年!"

Else

Print Str(year); Spc(2); "年茄鎮(zhèn)不是閏年!"

End If

End Sub

Public Sub runnian(n As Integer, x As Integer)

Dim leap As Integer

If n Mod 400 = 0 Then

leap = 1

ElseIf n Mod 4 = 0 And n Mod 100 稿納穗 0 Then

leap = 1

Else

leap = 0

End If

x = leap

End Sub

在vb點(diǎn)虐 中,如何計算出2000-2100年之間的閏年?輸出到文本框,并統(tǒng)計輸出閏年的個數(shù)?主要是統(tǒng)計個數(shù)

這樣:

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

Dim?leapyears()?As?Integer?=?GetLeapYears(2000,?2100)

Dim?str?As?String

Try

Dim?count?As?Integer?=?UBound(leapyears)?+?1

str?=?"閏年個數(shù):"?+?count.ToString

For?i?=?0?To?UBound(leapyears)

str?+=?"?"?+?leapyears(i).ToString

Next

TextBox1.Text?=?str

Catch?ex?As?Exception?

End?Try

End?Sub

'''?summary

'''?獲取指定年份區(qū)間中所有閏年組成的數(shù)組

'''?/summary

'''?param?name="StartYear"起始年饑配份/param

'''?param?name="EndYear"結(jié)束年份/param

'''?returns/returns

'''?remarks/remarks

Private?Function?GetLeapYears(StartYear?As?Integer,?EndYear?As?Integer)?As?Integer()

Dim?leapyears()?As?Integer?=?Nothing

Dim?index?As?Integer?=?0

For?i?=?StartYear?To?EndYear

If?(i?Mod?400?=?0)?Or?(i?Mod?4?=?0?And?i?Mod?100??0)?Then

ReDim?Preserve?leapyears(index)

leapyears(index)?=?i

index?+=?1

End?If

Next

Return?leapyears

End?Function

擴(kuò)展資料:

注意事項

DateSerial返回包含指定的年、月、日的 Variant (Date)。

語法:DateSerial(year, month, day)

Private Function MonthToLeapYear(ByVal Yea As Integer) As Boolean

MonthToLeapYear = Day(DateSerial(Yea, 2, 29)) = 29

End Function

Private Sub Command1_Click()

If Len(Text1.Text) = 4 Then

? If MonthToLeapYear(Text1.Text) = True Then

? ? ? Print Text1.Text "年是閏年"

? Else

? ? ? Print Text1.Text "年是平年"

? End If

Else

?Print "錯誤:請輸入正確的年份!"

End If

End Sub

在VB.NET中進(jìn)行日期處理時,避免手工判斷或計算是個好脊桐主意,因?yàn)槭止び嬎阌捎诖a的質(zhì)量問題可能不準(zhǔn)確??梢允褂?NET提供的類的功櫻肢坦能進(jìn)行日期處理。

例如,如果需要判斷給定的某年是否閏年,可以使用VB.NET的IsLeapYear函數(shù)。下面是如何使用該函數(shù)的一個例子:

Private Sub LeapYearCheck()

Dim bLeapYear AsBoolean

bLeapYear = Date.IsLeapYear(Now.Year)

MessageBox.Show(bLeapYear)

bLeapYear = Date.IsLeapYear(2004)

MessageBox.Show(bLeapYear)

End Sub

VB編程 判斷閏年

Private?Sub?Form_Click()

Dim?a?As?Integer

a?漏碰=?Val(InputBox("輸入年份"))

If?a?Mod?400?=?0?Then

Print?"是瑞年"

ElseIf?a?Mod?4?=?0?And?a?Mod?100??0?Then

Print?"是瑞此啟年?"

Else

Print?"返扒談不是瑞年"

End?If

End?Sub

VB.NET 根據(jù)年月日判斷是否為閏年或者平年!

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


網(wǎng)頁標(biāo)題:vbnet判斷閏年 web判斷閏年
本文URL:http://weahome.cn/article/ddpjhsh.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部