| | |
e.cancel simple problem??
Please support our VB.NET advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Apr 2007
Posts: 11
Reputation:
Solved Threads: 0
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:
any ideas? Thanks for any help in advance
They all start with the following initial code:
VB.NET Syntax (Toggle Plain Text)
Dim strPass As String = "123" ' The default password for exit Dim givenPass = InputBox("Please enter password to quit", "Quit?")
VB.NET Syntax (Toggle Plain Text)
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
VB.NET Syntax (Toggle Plain Text)
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
VB.NET Syntax (Toggle Plain Text)
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
i think this code is alright.
Last edited by Jx_Man; Apr 1st, 2008 at 4:51 pm.
Never tried = Never Know
So, Please do something before post your thread.
* PM Asking will be ignored *
So, Please do something before post your thread.
* PM Asking will be ignored *
Try this:
Hope this helps,
Johnny
vb Syntax (Toggle Plain Text)
Dim strPass As String = "123" ' The default password for exit Dim givenPass = InputBox("Please enter password to quit", "Quit?") If givenPass = strPass Then 'do nothing.. let them leave ElseIf givenPass = "" Then 'user click the cancel button MsgBox("You must enter a password.") e.Cancel = True Else 'password is wrong MsgBox("Your password is not correct. Please try again.") e.Cancel = True End If
Hope this helps,
Johnny
![]() |
Similar Threads
- Custom Message Box (Visual Basic 4 / 5 / 6)
- All folders open in new windows (Windows NT / 2000 / XP)
- Lost Windows XP user password (Windows NT / 2000 / XP)
- memory management in wndows 2000 (Windows NT / 2000 / XP)
- Problem downloading MS VC++ Express 2005 (C++)
- Another one of My Stupid Ideas (Windows 95 / 98 / Me)
- Collating (Java)
- Moving IBM DOS 5.0 to a different partition? (Windows 95 / 98 / Me)
- I get a "virus Alert" in toolbox (Viruses, Spyware and other Nasties)
- Need Help with "Please Insert Disk" message in Quark (Mac Software)
Other Threads in the VB.NET Forum
- Previous Thread: couple questions
- Next Thread: Search a .txt file for valid password.
| Thread Tools | Search this Thread |
"crystal .net .net2005 30minutes 2005 2008 access account arithmetic array basic binary bing button buttons center check code combobox component connectionstring crystalreport data database databasesearch datagrid datagridview design dissertation dissertations dissertationthesis dropdownlist excel file-dialog folder ftp generatetags google gridview hardcopy image images insert intel internet listview login math mobile monitor ms navigate net networking opacity output passingparameters peertopeervideostreaming picturebox picturebox1 port print problem problemwithinstallation project reports" save savedialog searchbox searchvb.net select serial soap string table tcp text textbox timer toolbox trim update updown user usercontrol vb vb.net vb.netcode vb.netformclosing()eventpictureboxmessagebox vb.nettoolboxvisualbasic2008sidebar vb2008 vbnet view visual visualbasic visualbasic.net visualstudio visualstudio2008 web wpf






