如题。
谢谢。

解决方案 »

  1.   

    Private Sub Command1_Click()
    On Error GoTo Err
    CommonDialog1.CancelError = True
        CommonDialog1.Filter = "Jpg (*.JPG)|*.JPG|BMP(*.BMP)|*.BMP"
        CommonDialog1.ShowOpen    If CommonDialog1.filename <> "" Then
            Image1.Picture = LoadPicture(CommonDialog1.filename)
            MsgBox Left(CommonDialog1.filename, InStrRev(CommonDialog1.filename, "\"))
            
        End IfErr:
        If Err.Number = 32755 Then
            MsgBox "你按了取消!", vbCritical, "系统提示"
        End If
    End Sub
      

  2.   

    关键:设置CommonDialog1.CancelError = True进行错误处理,捕获32755号错误
     
    Private Sub Command1_Click()
    On Error GoTo Err
    CommonDialog1.CancelError = True
    CommonDialog1.ShowOpen
    .....
    exit sub
    err:
    select case err.number
    case 32755
    MsgBox "你按了取消!"
    end select
    end sub
      

  3.   

    呵呵,我原来一直是以FileName属性是否为空来判断的,如果为空,则按了取消,否则按了确定。