You want to make it where a user can't close the form?
Code:
If CheckBox1.Checked = True Then
Me.ControlBox = False
Else
Me.ControlBox = True
End If
Would show/hide the control buttons (minimize, maximize, close).
Then just hide the program from taskmanager and use a work around to disable the alt+F4 key.
To block the alt+F4 from closing your program, import this code:
Code:
Private frmval As Boolean = True
Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
If (e.Alt) And (e.KeyValue = Keys.F4) Then
e.Handled = frmval
End If
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
AddHandler Me.KeyDown, AddressOf Me.Form1_KeyDown
End Sub
Then when you'd like to block the alt+f4 input, call this:
Code:
frmval = True 'disables alt+f4
AddHandler Me.KeyDown, AddressOf Me.Form1_KeyDown