将cancelerror设为false应该不会出现那样的问题吧

解决方案 »

  1.   

    CommonDialog1.FileName的值作怪,如果在保存的选择框中有选择到文件,那么文件那一栏就会不为空,而当然CommonDialog1.FileName肯定不会为空的,因为它是读那个文件名栏的。这时候只能够在CommonDialog1.CancelError = True上面一行加上错误陷阱。如下:
          CommonDialog1.ShowSave
          On Error Resume Next
          Err.number=0
          CommonDialog1.CancelError = True
          if Err.number=32755 then CommonDialog1.FileName=""      lpath= CommonDialog1.FileName
             If lpath <> "" Then
                SavePicture Image1.Picture, lpath
             Else
                Exit Sub
             End If   
        Else
              lpath= ""
       End If这样一个应该就可以了~~~~~^_^
      

  2.   

    将CancelError=True 放在showsave 前。
      

  3.   

    将CancelError=True 放在showsave 前。
      

  4.   

    用on error goto 来控制On Error GoTo err_control
        CommonDialog1.Filter = "片(*.bmp)|*.bmp|所有文件(*.*)|*.*"
           CommonDialog1.Flags = cdlOFNPathMustExist Or cdlOFNOverwritePrompt
           CommonDialog1.CancelError = True
           CommonDialog1.ShowSave
           
                                
           lpath = CommonDialog1.FileName
            SavePicture Image1.Picture, lpath
            Exit Sub
    err_control:
            If Err.Number = 32755 Then
                Exit Sub
            Else
            ' another error control
            End If
      

  5.   

    把CommonDialog1的属性CancelError设定为true.
    再代码前加入:
      on error goto errorhandle
         ret = MsgBox("要保存图形吗?", vbYesNo, "")
       If ret = 6 then 
            ......
            ......
           CommonDialog1.Filter = "图片(*.bmp)|*.bmp|所有文件(*.*)|*.*"
           CommonDialog1.Flags = cdlOFNPathMustExist Or cdlOFNOverwritePrompt
           CommonDialog1.ShowSave
           
          lpath= CommonDialog1.FileName
             If lpath <> "" Then
                SavePicture Image1.Picture, lpath
             Else
                Exit Sub
             End If
       
        Else
              lpath= ""
       End If
      exit sub
    errorhandle:
       exit sub