花了几个星期去完成一个VB实训项目,到今天可以说是告一节了,但是我还是留下一个问题:我的记事本里的打开对话框,当我打开我的对话框,点击“取消”时却出现了如下的错误提示,对此我很不解。我用的是visual studio 2010 VB 写的!我的代码如下:
Sub open_click()
'单击打开命令的处理过程
'如果当前编辑的文件内容被更改,提示用户保存文件
'将选取的文件内容显示到文本框中
Dim FilStr As String
Dim TempStr As String
Dim SaveIt As Integer
If Modified = True Then
SaveIt = MsgBox("文件" & Me.Text & "的正文已更改," & "是否保存更改?",vbYesNoCancel)
If SaveIt = 2 Then Exit Sub
If SaveIt = 6 Then
If FPath_Name <> "" Then
SaveFileDialog1.FileName = FPath_Name
SaveFileDialog1.Filter = "Text Files(*.txt)|*.txt|" & "All Files (*.*)|(*.*)"
SaveFileDialog1.ShowDialog()
If SaveFileDialog1.FileName <> "" Then
FileOpen(1,SaveFileDialog1.FileName,OpenMode.Output,OpenAccess.Default)
Print(1,TextBox1.Text)
FileClose(1)
End If
End If
End If
End If
OpenFileDialog1.Filter = "Text Files(*.txt)|*.txt|" & "All Files (*.*)|(*.*)"
OpenFileDialog1.ShowDialog()
If Windows.Forms.DialogResult.Cancel = True Then
Exit Sub
End If
If OpenFileDialog1.FileName = "" Then Exit Sub
FPath_Name = OpenFileDialog1.FileName
FileOpen(1,OpenFileDialog1.FileName,OpenMode.Input,OpenAccess.Read)
FilStr = ""
Do Until EOF(1)
TempStr = LineInput(1)
FilStr = FilStr & TempStr
Loop
FileClose(1)
Me.Text = OpenFileDialog1.FileName
TextBox1.Text = FilStr
End Sub
当我打开打开对话框,选择“取消”时出现下面的提示:并指到FileOpen(1,OpenAccess.Read)这条语句
请问我该如何修改!