VB.NET根据年月获得总周数

VB.NET根据年月获得总周数,第1张

概述  Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click MsgBox("总周数:" & GetTotalWeeks(Me.monthid.Text)) End Sub Private
    Private Sub button7_Click(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles button7.Click        MsgBox("总周数:" & GetTotalWeeks(Me.monthID.Text))    End Sub    Private Function GetTotalWeeks(ByVal monthID As String) As Integer        Dim y,m As String        y = monthID.Substring(0,4)        m = monthID.Substring(4)        Dim totalweeks As Integer        Dim FirstDayOfMonth As Date = New DateTime(y,m,1)        Dim LastDayOfMonth As Date = New DateTime(y,Date.DaysInMonth(y,m))        Dim d As Date = FirstDayOfMonth        Dim ed(0) As Date        Dim j As Int16        For i As Int16 = 0 To Date.DaysInMonth(y,m) - 1            If d.DayOfWeek = DayOfWeek.Saturday Then                ReDim Preserve ed(j)                ed(j) = d                j = j + 1            End If            d = d.AddDays(1)        Next        For i As Int16 = 0 To ed.Length - 1            MsgBox(ed(i))        Next        totalweeks = ed.Length        If ed(ed.Length - 1) <= LastDayOfMonth Then            totalweeks = totalweeks + 1        End If        Return totalweeks    End Function
VB.NET根据年月获得总周数 总结

以上是内存溢出为你收集整理的VB.NET根据年月获得总周数全部内容,希望文章能够帮你解决VB.NET根据年月获得总周数所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1287796.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-09
下一篇 2022-06-09

发表评论

登录后才能评论

评论列表(0条)

保存