Hey people, just a quick one here, as its getting quite annoying. Basically i want the form to only be closed when a correct password is entered using the form closing event. i have tried the following methods but they all seem to crash... any ideas?
They all start with the following initial code:
Dim strPass As String = "123" ' The default password for exit Dim givenPass = InputBox("Please enter password to quit", "Quit?")
If MsgBoxResult.Ok Then Select Case givenPass = strPass Case givenPass = Not strPass Or givenPass = "" e.Cancel = True End Select ElseIf MsgBoxResult.Cancel Then e.Cancel = True End If
If (givenPass = "" Or givenPass = Not strPass) And MsgBoxResult.Ok Then ' MsgBox("Password incorrect, please try again or consult user guide") ' e.Cancel = True ' ElseIf Windows.Forms.DialogResult.Cancel = True Then ' ElseIf givenPass = strPass Then ' End 'Else ' MsgBox("Unknown error, please try again") 'End If
Try 'Select Case MsgBoxResult.Ok And givenPass = strPass 'Do Nothing ' Case MsgBoxResult.Ok And givenPass = Not strPass Or givenPass = "" ' e.Cancel = True ' Case MsgBoxResult.Cancel ' e.Cancel = True ' End Select ' Catch ee As Exception 'Throw ee ' End Try
any ideas? Thanks for any help in advance