Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default Doing nothing when pressing Cancel on InputBox

Hello Guys, a rather simple thing, yet i don't know why it does not work:

the code asks simply for a password, if the password is correct, perform the
code. Or if the user typed nothing in the inputbox, or pressed Cancel, do
nothing. If the password is wrong, give message "wrong password".


response = InputBox("give password: ") = "abcdefg"
If response = vbNullString Then Exit Sub 'This code should exit the sub if
no typing or pressed on Cancel button
If response = "abcdefg" Then
'Code to execute Else
MsgBox "password incorrect!", vbCritical
End If

this doesn't work as it should, any ideas what's wrong?

Thanks in advance.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,533
Default Doing nothing when pressing Cancel on InputBox


"Memento" skrev i en meddelelse
...
Hello Guys, a rather simple thing, yet i don't know why it does not work:

the code asks simply for a password, if the password is correct, perform
the
code. Or if the user typed nothing in the inputbox, or pressed Cancel, do
nothing. If the password is wrong, give message "wrong password".


response = InputBox("give password: ") = "abcdefg"
If response = vbNullString Then Exit Sub 'This code should exit the sub if
no typing or pressed on Cancel button
If response = "abcdefg" Then
'Code to execute Else
MsgBox "password incorrect!", vbCritical
End If

this doesn't work as it should, any ideas what's wrong?

Thanks in advance.


Try this:

response = InputBox("give password: ") = "abcdefg"
If response = False Then Exit Sub 'This code should exit the sub if no
typing or pressed on Cancel button
If response = "abcdefg" Then
'Code to execute
Else
MsgBox "password incorrect!", vbCritical
End If

Regards,

Per


  #3   Report Post  
Posted to microsoft.public.excel.programming
Jay Jay is offline
external usenet poster
 
Posts: 671
Default Doing nothing when pressing Cancel on InputBox

Hi Memento -

response = InputBox("give password: ") '= "abcdefg"
'Following code should exit the sub if no typing Cancel
If response = vbNullString Then Exit Sub
If response = "abcdefg" Then
'Code to execute
MsgBox "Password Correct !", vbInformation
Else
MsgBox "password incorrect!", vbCritical
End If

---
Jay

"Memento" wrote:

Hello Guys, a rather simple thing, yet i don't know why it does not work:

the code asks simply for a password, if the password is correct, perform the
code. Or if the user typed nothing in the inputbox, or pressed Cancel, do
nothing. If the password is wrong, give message "wrong password".


response = InputBox("give password: ") = "abcdefg"
If response = vbNullString Then Exit Sub 'This code should exit the sub if
no typing or pressed on Cancel button
If response = "abcdefg" Then
'Code to execute Else
MsgBox "password incorrect!", vbCritical
End If

this doesn't work as it should, any ideas what's wrong?

Thanks in advance.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Doing nothing when pressing Cancel on InputBox

Maybe this:--

Sub getpass()
response = InputBox("give password: ")
If response = "" Then Exit Sub
If response = "abcdefg" Then
MsgBox "correct password entered"
Else
MsgBox "password incorrect!", vbCritical
End If

End Sub

Mike

"Memento" wrote:

Hello Guys, a rather simple thing, yet i don't know why it does not work:

the code asks simply for a password, if the password is correct, perform the
code. Or if the user typed nothing in the inputbox, or pressed Cancel, do
nothing. If the password is wrong, give message "wrong password".


response = InputBox("give password: ") = "abcdefg"
If response = vbNullString Then Exit Sub 'This code should exit the sub if
no typing or pressed on Cancel button
If response = "abcdefg" Then
'Code to execute Else
MsgBox "password incorrect!", vbCritical
End If

this doesn't work as it should, any ideas what's wrong?

Thanks in advance.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Doing nothing when pressing Cancel on InputBox

You can use strptr funtion ...........

response = InputBox("Enter password")
If StrPtr(pq) < 0 Then
'Code to execute
Else
MsgBox "password incorrect!", vbCritical
End If
Exit Sub

:) have a great time

Gaurav Kothari

"Memento" wrote:

Hello Guys, a rather simple thing, yet i don't know why it does not work:

the code asks simply for a password, if the password is correct, perform the
code. Or if the user typed nothing in the inputbox, or pressed Cancel, do
nothing. If the password is wrong, give message "wrong password".


response = InputBox("give password: ") = "abcdefg"
If response = vbNullString Then Exit Sub 'This code should exit the sub if
no typing or pressed on Cancel button
If response = "abcdefg" Then
'Code to execute Else
MsgBox "password incorrect!", vbCritical
End If

this doesn't work as it should, any ideas what's wrong?

Thanks in advance.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Test for Cancel in Inputbox Fred Smith Excel Programming 5 April 6th 07 03:36 AM
How do I capture CANCEL on an Inputbox? Toxicdistortion Excel Programming 3 October 27th 06 01:23 AM
How do I capture CANCEL on an Inputbox? Toxicdistortion Excel Programming 0 October 27th 06 12:37 AM
Help with inputbox (Distinguish OK from Cancel) NooK[_47_] Excel Programming 3 August 5th 04 11:45 AM
Clicking Cancel on an Inputbox rott[_6_] Excel Programming 3 March 5th 04 02:57 AM


All times are GMT +1. The time now is 11:51 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"