vb.net求第几周 vb的weekday函数

vb 计算某天是一年中的第几周非常简单,没有那么复杂吧?
If Text1.Text = "" Then
MsgBox "", 16, ""'以下对话框的提示内容自己填写吧!
Exit Sub
End If
If Text2.Text = "" Then
MsgBox "", 16, ""
Exit Sub
End If
If Text3.Text = "" Then
MsgBox "", 16, ""
Exit Sub
End If
If IsNumeric(Text1.Text) = False Or Val(Text1.Text)9999 Or Val(Text1.Text)1000 Then
MsgBox "", 16, ""
Exit Sub
End If
If IsNumeric(Text2.Text) = False Or Val(Text1.Text)12 Or Val(Text1.Text)1 Then
MsgBox "", 16, ""
Exit Sub
End If
If IsNumeric(Text3.Text) = False Then
MsgBox "", 16, ""
Exit Sub
End If
If Val(Text2.Text) = 1 Or Val(Text2.Text) = 3 Or Val(Text2.Text) = 5 Or Val(Text2.Text) = 7 Or Val(Text2.Text) = 8 Or Val(Text2.Text) = 10 Or Val(Text2.Text) = 12 Then
If Val(Text3.Text)31 Or Val(Text3.Text)1 Then
MsgBox "", 16, ""
Exit Sub
【vb.net求第几周 vb的weekday函数】End If
ElseIf Val(Text2.Text) = 4 Or Val(Text2.Text) = 6 Or Val(Text2.Text) = 9 Or Val(Text2.Text) = 11 Then
If Val(Text3.Text)30 Or Val(Text3.Text)1 Then
MsgBox "", 16, ""
Exit Sub
End If
ElseIf Val(Text2.Text) = 2 Then
If Val(Text1.Text) Mod 4 = 0 Then
If Val(Text3.Text)29 Or Val(Text3.Text)1 Then
MsgBox "", 16, ""
Exit Sub
End If
Else
If Val(Text3.Text)28 Or Val(Text3.Text)1 Then
MsgBox "", 16, ""
Exit Sub
End If
End If
End If
Dim year1 As String, month1 As String, day As String, Weekday1 As Integer, Weekday2 As String
year1 = Text1.Text
month1 = Text2.Text
day1 = Text3.Text
Weekday1 = Weekday(CDate(year1"-"month1"-"day1))
Select Case Weekday1
Case 0: Weekday2 = "星期六"
Case 1: Weekday2 = "星期日"
Case 2: Weekday2 = "星期一"
Case 3: Weekday2 = "星期二"
Case 4: Weekday2 = "星期三"
Case 5: Weekday2 = "星期四"
Case 6: Weekday2 = "星期五"
End Select
VB计算一年中某一天在这一年中是第几周Private Sub btnGo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGo.ClickDim date1 As Date = txtDate.TextDim date0 = Year(date1)"/01/01"Dim wk = DateDiff("ww", date0, date1, Microsoft.VisualBasic.FirstDayOfWeek.Monday, FirstWeekOfYear.FirstFullWeek)If (wk = 0) Then//判断周数是否为0,为0则为去年最后一周Dim date2 = Year(date1) - 1Dim date3 = date2"/12/31"Dim date4 = date2"/01/01"wk = DateDiff("ww", date4, date3, Microsoft.VisualBasic.FirstDayOfWeek.Monday, FirstWeekOfYear.FirstFullWeek)End IflblShow.Text = txtDate.Text"是"Year(date1)"第"wk"周!"End Sub
vb.net中怎么根据日期算出是周几呢?Public Function IsRunnian(ByVal n As Integer) As Boolean
Dim res As Boolean
res = False
If n Mod 400 = 0 Then
res = True
End If
If (n Mod 1000) And (n Mod 4 = 0) Then
res = True
End If
IsRunnian = res
End Function
Public Function Fc(ByVal td As Date) As Byte
Dim y As Integer
Dim m As Integer
Dim d As Integer
Dim yc As Integer
Dim mc As Integer
Dim dc As Integer
y = Year(td)
m = Month(td)
d = Day(td)
dc = d
If IsRunnian(y) Then
mc = Val(Mid("512503514624", m, 1))
Else
mc = Val(Mid("622503514624", m, 1))
End If
yc = ((y Mod 100) \ 4 + (y Mod 100)) Mod 7
Fc = (yc + mc + dc) Mod 7
End Function
vb.net求第几周的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于vb的weekday函数、vb.net求第几周的信息别忘了在本站进行查找喔 。

    推荐阅读