精華區beta Programming 關於我們 聯絡資訊
> uglyman 撰寫於文章 <78j4rj$1g24$1@info.nsysu.edu.tw>... > Option Explicit > > Private Sub cmdColor_Click() > dlgcommon.CancelError = True > On Error GoTo DoNothing > dlgcommon.ShowColor > frmCommon.BackColor = dlgcommon.color > Exit Sub > DoNothing: > If Err.Number = cdlCancel Then > End If > End Sub > > Private Sub cmdExit_Click() > End > End Sub > > Private Sub cmdPicture_Click() > dlgcommon.CancelError = True > On Error GoTo DoNothing > dlgcommon.Filter = "Display *.jeg *.gif|*.jeg;*.gif" > dlgcommon.ShowOpen > imgImage.Picture = LoadPicture(dlgcommon.filename) > Exit Sub > DoNothing: > If Err.Number = cdlCancel Then > Else: > Beep > MsgBox Err.Description > End If > End Sub Err.Number=cdlControl 是指在 CommonDialog 中按下 "取消" 鍵,也就是你要把處理 程序放在 If Err.Number = cdlCancel Then Else 之間,才會有處理動作,如果不是 cdlCancel 的情況,才 MsgBox Err.Description ,也就是說雖然你讓 dlgcommon.CancelError = True 但實際上一點作用都沒有。