vb点虐 求第几周 vb显示星期几
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
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.Click Dim date1 As Date = txtDate.Text Dim 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) - 1 Dim date3 = date2 "/12/31" Dim date4 = date2 "/01/01" wk = DateDiff("ww", date4, date3, Microsoft.VisualBasic.FirstDayOfWeek.Monday, FirstWeekOfYear.FirstFullWeek) End If lblShow.Text = txtDate.Text "是" Year(date1) "第" wk "周!"End Sub
vb点虐 中怎么根据日期算出是周几呢?
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 100 0) 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点虐 求第几周 vb显示星期几
转载来源:http://hbruida.cn/article/ddshpop.html