根据文本框中输入的年份,计算该年的元旦是星期几,求vb程序代码
发布网友
发布时间:2022-04-27 07:03
我来回答
共4个回答
热心网友
时间:2023-09-13 02:26
Private Sub Command1_Click()
Dim K
Dim StrT
StrT = "日一二三四五六"
K = Text1 & "-01-01"
If IsDate(K) = False Then
MsgBox "输入年份错误", vbInformation, "错误"
Text1 = ""
Text1.SetFocus
Exit Sub
End If
MsgBox K & " 星期" & Mid(StrT, Weekday(K), 1), vbInformation, "结果"
End Sub
热心网友
时间:2023-09-13 02:26
Private Sub Command1_Click()
Dim Y As Integer, W As Single, Day As Integer
Y = Val(Text1.Text)
W = (Y - 1) + (Y - 1) / 4 - (Y - 1) / 100 + (Y - 1) / 400 + 1
W = Fix(W)
Day = W Mod 7
Select Case Day
Case 1
Print Str(Y) & "年的元旦是星期一"
Case 2
Print Str(Y) & "年的元旦是星期二"
Case 3
Print Str(Y) & "年的元旦是星期三"
Case 4
Print Str(Y) & "年的元旦是星期四"
Case 5
Print Str(Y) & "年的元旦是星期五"
Case 6
Print Str(Y) & "年的元旦是星期六"
Case 0
Print Str(Y) & "年的元旦是星期日"
End Select
End Sub
满意的话请采纳哦~
热心网友
时间:2023-09-13 02:27
#include <stdio.h>
void main ()
{
int y,m,d,c,s,w;
printf("请输入8位年月日,以空格隔开:");
scanf("%d%d%d",&y,&m,&d);
if (m==1) c=d;
else if (m==2) c=31+d;
else if (m==3) c=31+28+d;
else if (m==4) c=31+28+31+d;
else if (m==5) c=31+28+31+30+d;
else if (m==6) c=31+28+31+30+31+d;
else if (m==7) c=31+28+31+30+31+30+d;
else if (m==8) c=31+28+31+30+31+30+31+d;
else if (m==9) c=31+28+31+30+31+30+31+31+d;
else if (m==10) c=31+28+31+30+31+30+31+31+30+d;
else if (m==11) c=31+28+31+30+31+30+31+31+30+31+d;
else if (m==12) c=31+28+31+30+31+30+31+31+30+31+30+d;
if (m>2)
{if (y%100==0) {if (y%400==0) c=c+1;}
else if (y%4==0) c=c+1;}
s=(y-1)*365+(y-1)/4-(y-1)/100+(y-1)/400+c;
w=s%7;
switch (w)
{
case 0: printf("星期日");break;
case 1: printf("星期一");break;
case 2: printf("星期二");break;
case 3: printf("星期三");break;
case 4: printf("星期四");break;
case 5: printf("星期五");break;
case 6: printf("星期六");break;
printf("\n");
}
热心网友
时间:2023-09-13 02:27
Private Sub Command1_Click()
Dim x As Long, y As Long, w As Long
x = Text1
y = x - 1 + Fix((x - 1) / 4) - Fix((x - 1) / 100) + Fix((x - 1) / 400) + 1
w = y Mod 7
Text2 = CStr(w)
End Sub
Private Sub Command2_Click()
End
End Sub