微生物检验员培训机构:记录上机时间的一个小程序,不够好,帮帮忙

来源:百度文库 编辑:杭州交通信息网 时间:2024/03/29 15:44:54
因为最近有学VB的热情,就想针对宿舍电费问题而编了这小程序,觉得还有很多的不足,比如一个月满的时候是应该把a、b的值改为零,重新记录,但是我试了很多次还是不行,请各位指教一下

Dim a As Integer, b As Integer
Private Sub Command1_Click()
Text1.Text = Str(a \ 60) & "小时" & Str(a Mod 60) & "分钟" '输出本次上机时间
Text2.Text = Str(b \ 60) & "小时" & Str(b Mod 60) & "分钟" '输出本月上机时间
End Sub

Private Sub Form_Load()
Dim i As Integer, x As String
Open "D:\我的文档\我的vb制作\上机时间管理系统\记录.txt" For Input As #1 '读取上次上机时间
i = 1
Do While Not EOF(1)
Line Input #1, x
If i = 0 Then
a = Val(x)
ElseIf i = 1 Then
b = Val(x)
End If
Loop
Close #1
End Sub
Private Sub Timer1_Timer()
a = a + 1
b = b + 1
Open "D:\我的文档\我的vb制作\上机时间管理系统\记录.txt" For Output As #1 '每一分钟记录一次(写入txt文档)
Print #1, a
Print #1, b
Close #1
End Sub