当前位置:编程学习 > VB >>

大家帮我看看代码哪有问题

Private Sub OpenFile_Click()
On Error GoTo errhander
CommonDialog1.Filter = "all files(*.*)|*.*|" & "executable files(*.exe)|*.exe|" & "text files(*.txt)|*.txt|"
CommonDialog1.FilterIndex = 2
CommonDialog1.ShowOpen
MyOpenFileSub
errhandler:
Exit Sub
End Sub --------------------编程问答-------------------- 就是标号错了

On Error GoTo errhander 
CommonDialog1.Filter = "all files(*.*) ¦*.* ¦" & "executable files(*.exe) ¦*.exe ¦" & "text files(*.txt) ¦*.txt ¦" 
CommonDialog1.FilterIndex = 2 
CommonDialog1.ShowOpen 
MyOpenFileSub 
errhandler: 
--------------------编程问答-------------------- 呵,我是新手
能说清楚点吗
你是说上面的errhandler少了个字母l吗 --------------------编程问答-------------------- 哈哈....就是啊, 少了 L

再补充一下:

Private Sub OpenFile_Click() 
   On Error GoTo errhandler 
   '看你的Filter那个分隔符也怪怪的....
   CommonDialog1.Filter = "执行文件(*.exe)|*.exe|文本文件(*.txt)|*.txt|所有文件(*.*)|*.*" 
   CommonDialog1.FilterIndex = 2 
   CommonDialog1.ShowOpen 
   call MyOpenFileSub 
errhandler: 
   if err>0 then Exit Sub 
End Sub

--------------------编程问答-------------------- 谢谢
你写的代码咋多了个CALL语句和 if err> 0 then 
这个也要补充上去吗 --------------------编程问答-------------------- 朋友不行啊
运行显示 子程序或函数未定义

--------------------编程问答-------------------- 不需要补了。
Private Sub OpenFile_Click ()
        '设计程序时将CancelError 为 True。
          On Error GoTo ErrHandler
        '设置过滤器。
         CommonDialog1.Filter = "All Files (*.*)|*.*|Text Files (*.txt)|*.txt|Batch Files(*.bat)|*.bat"
        '指定缺省过滤器。
         CommonDialog1.FilterIndex = 2
        '显示“打开”对话框。
         CommonDialog1.ShowOpen
        '调用打开文件的过程。
         OpenFile (CommonDialog1.FileName)
ErrHandler: '用户按了“取消”按钮。              
End Sub

--------------------编程问答-------------------- 还是不行
显示“属性的使用无效”
补充:VB ,  基础类
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,