|
-
Apr 6th, 2000, 07:56 PM
#1
Thread Starter
Lively Member
Hello I am using the following code for an input box and when I just click the cancel button that is given for the input box it still says " Incorrect Password" when I want it to just close out the inputbox. Sooo how do you code for if cancel then exit sub. Thanks.
myvalue = InputBox("Please Enter Password:", "Edit Agents")
If myvalue <> "manager" Then
ElseIf myvalue <> "manager" Then
MsgBox "Incorrect Password", vbOKOnly + vbInformation, "Denied"
Exit Sub
End If
IE:::::::::: but does not work
If Cancel = vbCancel Then
Exit Sub
End If
-
Apr 6th, 2000, 10:11 PM
#2
Hyperactive Member
Hi,
I changed your code to a select case branch.
If you want to keep your structure add another "If" statement in your first one to test to see if the returned value is "". That is what the input box returns if cancel was pressed.
Code:
myvalue = InputBox("Please Enter Password:", "Edit Agents")
Select Case myvalue
Case Is <> "manager"
If myvalue = "" Then
MsgBox "Canceled"
Else
MsgBox "Correct Password", 64, "Thanks"
End If
Exit Sub
Case "manager"
MsgBox "Incorrect Password", vbOKOnly + vbInformation, "Denied"
Exit Sub
End Select
Let us know if that helped.
JazzBass
JazzBass
In the .NET era
Trying to remember VB6
Progress: 
XP Professional @ Home
and @ the Office
-
Apr 6th, 2000, 10:20 PM
#3
Junior Member
I believe that if the cancel button is invoked then it defaults the input variable to nothing so try this
myvalue = InputBox("Please Enter Password:", "Edit Agents")
Select Case myvalue
Case Is <> "manager"
If myvalue = "" Then
'Enter any cancel message
Exit sub
Else
MsgBox "Incorrect password"
'Incorrect procedure
End If
Case "manager"
MsgBox "Incorrect Password", vbOKOnly + vbInformation, "Denied"
Exit Sub
End Select
Hope this helps
-
Apr 6th, 2000, 10:45 PM
#4
Hyperactive Member
UK Phil - That's right
Hey,
Yeah, your right. When a user cancels out of a Inputbox, it returns nothing. That is shown in my code as the two double quotes in the "If" statement.
JazzBass
-
Apr 6th, 2000, 11:18 PM
#5
Junior Member
To JazzBass
Yep, I wrote that whilst you were posting yours and didn't realise until afterwards. Nice to know that though. Another problem solved!!
Cheers
-
Apr 6th, 2000, 11:35 PM
#6
Hyperactive Member
To UKPhil
Cool!
JazzBass
In the .NET era
Trying to remember VB6
Progress: 
XP Professional @ Home
and @ the Office
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|