请问这道VB上机题为什么退出时间会提示实时错误424

来源:百度知道 编辑:UC知道 时间:2024/05/15 10:27:10
这是一道VB上机题,题目的大体意思是做三个text,做两个option,当选中第一个op1时,单击窗体,刚text1和text2的内容互换,然后text3显示OK,如果op2选中时,单击窗体,把text1和text2的内容连起来放在 text3,然后给出的已经有程序中有这么一段

Private Sub Form_Unload(Cancel As Integer)
Open "out3.txt" For Output As #1
Print #1, Opt1.Value, Opt2.Value, Text1.Text, Text2.Text, Text3.Text
Close #1
End Sub

以下是我自己加入的程序代码
Private Sub Form_Click()
If Op1.Value = True Then
Dim Str As String
Str = Text1.Text
Text1.Text = Text2.Text
Text2.Text = Str
Text3.Text = "OK"
End If

If Op2.Value = True Then
Text3.Text = Text1.Text + Text2.Text
End If
End Sub

程序在运行时没有问题,但一点关闭按钮的时候总提示“实时错误”424。请问这是为什么

opt1,text1...中的某一个或几个不存在.仔细检查控件的name属性与你程序中的是否一致.

Open "out3.txt" For Output As #1
这里的文件名没有指定路径,指定个路径试试。