月中的星期、年中的月、年

Week of month, month of year,year

我想检查月中的周数、年中的月和年,但我对月中的周有疑问 这是代码:

Public Class BMW
    Public Shared Function GetWeekNumber() As Integer
        Threading.Thread.Sleep(2000)

        Dim span As TimeSpan = DateTime.Now - New Date(DateTime.Now.Year, 1, 1)
        Return (CInt(span.TotalDays) \ 7) + 1

        If span.TotalDays = 1 Then

            SendKeys.Send("{1}")
            MsgBox(span.TotalDays)

        Else
            MsgBox("chybi1")
end if
end function

Google是你的朋友:

Private Function GetWeekNumber() As Integer
    Dim span As TimeSpan = DateTime.Now - New Date(DateTime.Now.Year, 1, 1)
    Return (CInt(span.TotalDays) \ 7) + 1
End Function

我什至不确定这就是你要找的..

Public Shared Function GetWeekNumber(ByVal datum As Date) As Integer

    Dim weeknumber = Math.Floor(datum.Day / 7 + +1)

    SendKeys.Send(weeknumber)
    Return weeknumber

End Function