下面的代码意思是,vb编程 按Command1复制Text1+text2的输入内容时,在同一天,如已经复制过同样内容则弹出对话框提示,“今天已经复制过该内容!”按“是”确认,按“否”取消。 补充说明:复制命令重复不提示,同一天复制的内容相同时才提示。运行时提示 实时错误62。超出文件尾 Line Input #1, strTmp变黄色。 帮我运行看看这段代码,改改还有什么地方错误。
Private Sub Command1_Click()
Dim strTmp As StringIf Dir(App.Path & "\copied.txt") = "" Then
Open App.Path & "\copied.txt" For Output As #1
Print #1, Date
Close #1
Else
Open App.Path & "\copied.txt" For Input As #1
Line Input #1, strTmp If CDate(strTmp) <> Date Then
Close #1
Open App.Path & "\copied.txt" For Output As #1
Print #1, Date
Close #1
Else
Do Until EOF(1)
Line Input #1, strTmp
If strTmp = Text1 & Text2 Then
If MsgBox("今天已经复制过该内容!", vbOKCancel) = vbCancel Then
Close #1
Exit Sub
End If
Exit Do
End If
Loop
Close #1
End If
End If
Clipboard.Clear
Clipboard.SetText Text1 & Text2.TextOpen App.Path & "\copied.txt" For Append As #1
Print #1, Text1.Text & Text2.Text
Close #1
End Sub
Private Sub Command1_Click()
Dim strTmp As StringIf Dir(App.Path & "\copied.txt") = "" Then
Open App.Path & "\copied.txt" For Output As #1
Print #1, Date
Close #1
Else
Open App.Path & "\copied.txt" For Input As #1
Line Input #1, strTmp If CDate(strTmp) <> Date Then
Close #1
Open App.Path & "\copied.txt" For Output As #1
Print #1, Date
Close #1
Else
Do Until EOF(1)
Line Input #1, strTmp
If strTmp = Text1 & Text2 Then
If MsgBox("今天已经复制过该内容!", vbOKCancel) = vbCancel Then
Close #1
Exit Sub
End If
Exit Do
End If
Loop
Close #1
End If
End If
Clipboard.Clear
Clipboard.SetText Text1 & Text2.TextOpen App.Path & "\copied.txt" For Append As #1
Print #1, Text1.Text & Text2.Text
Close #1
End Sub
我的代码是这样的:
Private Sub Command2_Click()
Static nn As Long 'Integer '
Dim aa As Stringnn = nn + 1
Open "c:\abc.txt" For Input As #1For i = 1 To nn
Line Input #1, aa '要处理没法返回
Next
Close #1
Text1.Text = aa '
Form1.Command3 = Form1.Command2
Command2.Visible = False '这段是隐藏按钮代码End Sub