不对啊!是不是电脑报出错了??
昨天翻阅《电脑报》发现在去年的电脑报上有一个小程序很有趣,它可以记录开机、关机时间。它使用VB,但是我把报纸上的文章输入到电脑里面的时候发现无法编译成为EXE文件,请大家帮我看看源程序有哪里错了?不然为什么无法编译成EXE文件?
源程序如下:(本例无需窗体)
Dim begintime
Private Sub Form_Load()
Me.Hide
begintime = Now
End Sub
Private Sub Form_UnLoad(Cancel As Integer)
endtime = Now
n = DateDiff("N", begintime, endtime)
Dim fso As New FileSystemObject
Dim txtfile As TextStream
Set a = App
If fso.FileExists(a.Path & "\开机纪录.txt") Then
Set txtfile = fso.OpenTextFile(a.Path & "\开机纪录.txt", ForAppending)
Else
Set txtfile = fso.OpenTextFile(a.Path & "\开机纪录.txt", ForWriting, True)
End If
txtfile.Write "开机时间" & begintime
txtfile.Write " " & "关机时间" & endtime
txtfile.Write " " & "时间长度" & n & "分钟"
txtfile.WriteBlankLines 2
End Sub
Dim begintime
Private Sub Form_Load()
Me.Hide
begintime = Now
End Sub
Private Sub Form_UnLoad(Cancel As Integer)
endtime = Now
n = DateDiff("N", begintime, endtime)
Dim fso As New FileSystemObject
Dim txtfile As TextStream
Set a = App
If fso.FileExists(a.Path & "\开机纪录.txt") Then
Set txtfile = fso.OpenTextFile(a.Path & "\开机纪录.txt", ForAppending)
Else
Set txtfile = fso.OpenTextFile(a.Path & "\开机纪录.txt", ForWriting, True)
End If
txtfile.Write "开机时间" & begintime
txtfile.Write " " & "关机时间" & endtime
txtfile.Write " " & "时间长度" & n & "分钟"
txtfile.WriteBlankLines 2
End Sub
Dim begintime
Private Sub Form_Load()
Me.Hide
begintime = Now
End Sub
Private Sub Form_UnLoad(Cancel As Integer)
endtime = Now
n = DateDiff("N", begintime, endtime)
Dim fso As New FileSystemObject
Dim txtfile As TextStream
Set a = App
If fso.FileExists(a.Path & "\开机纪录.txt") Then
Set txtfile = fso.OpenTextFile(a.Path & "\开机纪录.txt", ForAppending)
Else
Set txtfile = fso.OpenTextFile(a.Path & "\开机纪录.txt", ForWriting, True)
End If
txtfile.Write "开机时间" & begintime
txtfile.Write " " & "关机时间" & endtime
txtfile.Write " " & "时间长度" & n & "分钟"
txtfile.WriteBlankLines 2
End Sub