private sub form1_closing(byval sender as object, byval e as system.componentmodel.canceleventargs) handles mybase.closing if msgbox("請注意看關閉的視窗", msgboxstyle.question + msgboxstyle.okcancel, "關閉") = msgboxresult.ok then dim d as double for d = 1 to 0 + 0.2 step -0.2 system.threading.thread.sleep(50) application.doevents() me.opacity = d me.refresh() next d else e.cancel = true end if '1.設視窗為form1 '2.將變數命名為d '3.依物件名稱適當更改程式碼 end sub