The Quit button

I thought we had this already.

Use this code in a button labeled quit or edit the code to make it work inside a program

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim UserChoice As Integer
UserChoice = MsgBox(“Do you want to quit”, vbYesNo)
If UserChoice = vbYes Then me.close()
End Sub

2 thoughts on “The Quit button”

  1. You could use End rather than me.close() however End is a messy way to stop a program. It leaves all any open resources open.

Comments are closed.