引入两个按钮,根据弹出式对话框的不同回答来处理
控件:button1,button2
代码:
- Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
- MsgBox("button2")
- End Sub
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- If MessageBox.Show("要运行第二个按钮的事件吗?", "系统提示:", MessageBoxButtons.YesNo) = Windows.Forms.DialogResult.Yes Then
- Button2.PerformClick() '执行第二个代码的事件
- End If
- End Sub