Visual Basic 2005express edition

2006-10-14 8:43 am
每一個視窗的右上角都有個交叉比人地即走,
但係如果我想o係人地按之後再問多次佢係唔係真係想走,
咁我o係Visual Basic 2005express edition 度可以點打?

回答 (2)

2006-10-14 10:36 am
✔ 最佳答案
- Double click your form to bring you to the editor.

- On top of the editor, you’ll see 2 combo boxes

- On the left combo box, choose events (e.g. Form1 Events)

- On the right one, choose the ’FormClosing’ event. You can write your code here. Below is the example for asking confirmation before closing.


Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As _
 System.Windows.Forms.FormClosingEventArgs) Handles _
 Me.FormClosing

 If MessageBox.Show(’’Confirm exit?’’, ’’Exit’’, _
  MessageBoxButtons.YesNo) = _
  Windows.Forms.DialogResult.Yes Then
  e.Cancel = False
 Else
  e.Cancel = True
 End If

End Sub
2006-10-14 5:17 pm
你係程式碼模式下,係上便會有兩個拉下式清單,係左邊選番(form events),右邊選FormClosing

會加入以下程式:
Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing

End Sub

係end sub之前加入
If MessageBox.Show("內容","title", MessageBoxButtons.YesNo) = Windows.Forms.DialogResult.No Then
e.Cancel = True
End If


收錄日期: 2021-04-13 16:47:45
原文連結 [永久失效]:
https://hk.answers.yahoo.com/question/index?qid=20061014000051KK00231

檢視 Wayback Machine 備份