转眼间,就快要开学了。因此,我做了个电子课程表,可以根据电脑上的时间日期来显示当天课程.
我做了两种课程表,一种是C语言和VB的,另一种是VB和DOS的.两个运行效果完全相同.课程表内容在对应文本
文件中填写.
截图:
VB和DOS源代码:(自己用VB6.0编译.亲测好用)
Private Sub Form_Load()
Dim w
Form1.Hide
w = Weekday(Now)
If w = "1" Then
MsgBox ("今天休息")
End
End If
If w = "2" Then
Shell ("cmd.exe /k type Monday.txt&pause&exit"), vbNormalFocus
End
End If
If w = "3" Then
Shell ("cmd.exe /k type Tuesday.txt&pause&exit"), vbNormalFocus
End
End If
If w = "4" Then
Shell ("cmd.exe /k type Wednesday.txt&pause&exit"), vbNormalFocus
End
End If
If w = "5" Then
Shell ("cmd.exe /k type Thursday.txt&pause&exit"), vbNormalFocus
End
End If
If w = "6" Then
Shell ("cmd.exe /k type Friday.txt&pause&exit"), vbNormalFocus
End
End If
If w = "7" Then
MsgBox ("今天休息")
End
End If
End Sub
VB和C版:
VB部分如下:
Private Sub Form_Load()
Dim w
Form1.Hide
w = Weekday(Now)
If w = "1" Then
MsgBox ("今天休息")
End
End If
If w = "2" Then
Shell ("monday.exe"), vbNormalFocus
End
End If
If w = "3" Then
Shell ("tuesday.exe"), vbNormalFocus
End
End If
If w = "4" Then
Shell ("wednesday.exe"), vbNormalFocus
End
End If
If w = "5" Then
Shell ("thursday.exe"), vbNormalFocus
End
End If
If w = "6" Then
Shell ("friday.exe"), vbNormalFocus
End
End If
If w = "7" Then
MsgBox ("今天休息")
End
End If
End Sub
C语言部分如下:(用VC编译)
#include <stdio.h>
main()
{
char monday;
FILE*mon;
mon=fopen("Monday.txt","rt");
monday=fgetc(mon);
while (monday!=EOF)
{
printf("%c",monday);
monday=fgetc(mon);
}
fclose(mon);
getch();
}
这是周一的程序.周二周三周四周五只需改Monday.txt为对应文件即可.
说明:
建议使用VB和DOS.
保证Monday.txt,Tuesday.txt,Wednesday.txt,Thursday.txt,Friday.txt与程序在同一文件夹.
图片中显示的效果需要你在txt中自己去做.
请保证电脑系统时间准确,避免判断失误.
我做了两种课程表,一种是C语言和VB的,另一种是VB和DOS的.两个运行效果完全相同.课程表内容在对应文本
文件中填写.
截图:
VB和DOS源代码:(自己用VB6.0编译.亲测好用)
Private Sub Form_Load()
Dim w
Form1.Hide
w = Weekday(Now)
If w = "1" Then
MsgBox ("今天休息")
End
End If
If w = "2" Then
Shell ("cmd.exe /k type Monday.txt&pause&exit"), vbNormalFocus
End
End If
If w = "3" Then
Shell ("cmd.exe /k type Tuesday.txt&pause&exit"), vbNormalFocus
End
End If
If w = "4" Then
Shell ("cmd.exe /k type Wednesday.txt&pause&exit"), vbNormalFocus
End
End If
If w = "5" Then
Shell ("cmd.exe /k type Thursday.txt&pause&exit"), vbNormalFocus
End
End If
If w = "6" Then
Shell ("cmd.exe /k type Friday.txt&pause&exit"), vbNormalFocus
End
End If
If w = "7" Then
MsgBox ("今天休息")
End
End If
End Sub
VB和C版:
VB部分如下:
Private Sub Form_Load()
Dim w
Form1.Hide
w = Weekday(Now)
If w = "1" Then
MsgBox ("今天休息")
End
End If
If w = "2" Then
Shell ("monday.exe"), vbNormalFocus
End
End If
If w = "3" Then
Shell ("tuesday.exe"), vbNormalFocus
End
End If
If w = "4" Then
Shell ("wednesday.exe"), vbNormalFocus
End
End If
If w = "5" Then
Shell ("thursday.exe"), vbNormalFocus
End
End If
If w = "6" Then
Shell ("friday.exe"), vbNormalFocus
End
End If
If w = "7" Then
MsgBox ("今天休息")
End
End If
End Sub
C语言部分如下:(用VC编译)
#include <stdio.h>
main()
{
char monday;
FILE*mon;
mon=fopen("Monday.txt","rt");
monday=fgetc(mon);
while (monday!=EOF)
{
printf("%c",monday);
monday=fgetc(mon);
}
fclose(mon);
getch();
}
这是周一的程序.周二周三周四周五只需改Monday.txt为对应文件即可.
说明:
建议使用VB和DOS.
保证Monday.txt,Tuesday.txt,Wednesday.txt,Thursday.txt,Friday.txt与程序在同一文件夹.
图片中显示的效果需要你在txt中自己去做.
请保证电脑系统时间准确,避免判断失误.