用VB编写输入日期判断是一年中的第几天
推荐于2020-12-31
展开全部
Private Sub Form_Load()
Label1.Caption = "请输入日期【日期格式年-月旦山-日,慧迟磨如:2010-04-08】"
Text1.Text = Date
End SubPrivate Sub Command1_Click()
Dim i, n, myYear, myMonth, myDay, myWeek, Days As IntegermyYear = Year(Text1.Text)
myMonth = Month(Text1.Text)
myDay = Day(Text1.Text)n = myDay
For i = 1 To myMonth - 1
Select Case i
Case 1, 3, 5, 7, 8, 10, 12
Days = 31
Case 4, 6, 9, 11
Days = 30
Case 2
If (myYear Mod 4 = 0) And (myYear Mod 100 <> 0) Or (myYear Mod 400 = 0) Then
Days = 29
Else
Days = 28
End If
End Select
n = n + Days
Next
MsgBox Trim(Text1.Text) & "是一年前斗中的第" & Format(n) & "天。"End Sub
Label1.Caption = "请输入日期【日期格式年-月旦山-日,慧迟磨如:2010-04-08】"
Text1.Text = Date
End SubPrivate Sub Command1_Click()
Dim i, n, myYear, myMonth, myDay, myWeek, Days As IntegermyYear = Year(Text1.Text)
myMonth = Month(Text1.Text)
myDay = Day(Text1.Text)n = myDay
For i = 1 To myMonth - 1
Select Case i
Case 1, 3, 5, 7, 8, 10, 12
Days = 31
Case 4, 6, 9, 11
Days = 30
Case 2
If (myYear Mod 4 = 0) And (myYear Mod 100 <> 0) Or (myYear Mod 400 = 0) Then
Days = 29
Else
Days = 28
End If
End Select
n = n + Days
Next
MsgBox Trim(Text1.Text) & "是一年前斗中的第" & Format(n) & "天。"End Sub
2013-06-17
展开全部
dim it2 as date,dim it1 as date it2是你输掘氏老核誉入的日期dim i as integerit1=#year(it2)-1-1#i=datediff("d"判升,it1,it2)+1
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询