Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 201
Default InputBox Function & Cancel

Excel 2002, WinXP
I am using the InputBox Function to get some info from the user.
I want to trap the instance of the user clicking the Cancel button.
Clicking on the Cancel button returns a zero-length string.
No input and clicking on the OK button also returns a zero-length string.
Is there a way to differentiate between the two actions?

I realize that I can use the InputBox Method and specify a type and thereby
force the user to input something. Also the Cancel button returns a False.
Thanks for your help. Otto


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default InputBox Function & Cancel

Hi Otto,

You can use the StrPtr function:

Sub Tester()
Dim strInput As String

strInput = InputBox("Complete this quotation", _
"InputBox Demo", _
"Friends, Romans and Countrymen")
If StrPtr(strInput) = 0 Then
MsgBox "You pressed Cancel"
Else
If Len(strInput) = 0 Then
MsgBox "OK was pressed but no entry was made."
Else
MsgBox "Your entry was: " & strInput
End If
End If
End Sub

For information about StrPtr see Karl Peterson's site:

http://www.mvps.org/vb/index2.html?tips/varptr.htm


---
Regards,
Norman



"Otto Moehrbach" wrote in message
...
Excel 2002, WinXP
I am using the InputBox Function to get some info from the user.
I want to trap the instance of the user clicking the Cancel button.
Clicking on the Cancel button returns a zero-length string.
No input and clicking on the OK button also returns a zero-length string.
Is there a way to differentiate between the two actions?

I realize that I can use the InputBox Method and specify a type and
thereby force the user to input something. Also the Cancel button returns
a False.
Thanks for your help. Otto



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,327
Default InputBox Function & Cancel

Hi Norman

I stand corrected. This was good, thanks.

Best wishes Harald

"Norman Jones" skrev i melding
...
Hi Otto,

You can use the StrPtr function:

Sub Tester()
Dim strInput As String

strInput = InputBox("Complete this quotation", _
"InputBox Demo", _
"Friends, Romans and Countrymen")
If StrPtr(strInput) = 0 Then
MsgBox "You pressed Cancel"
Else
If Len(strInput) = 0 Then
MsgBox "OK was pressed but no entry was made."
Else
MsgBox "Your entry was: " & strInput
End If
End If
End Sub

For information about StrPtr see Karl Peterson's site:

http://www.mvps.org/vb/index2.html?tips/varptr.htm


---
Regards,
Norman



"Otto Moehrbach" wrote in message
...
Excel 2002, WinXP
I am using the InputBox Function to get some info from the user.
I want to trap the instance of the user clicking the Cancel button.
Clicking on the Cancel button returns a zero-length string.
No input and clicking on the OK button also returns a zero-length

string.
Is there a way to differentiate between the two actions?

I realize that I can use the InputBox Method and specify a type and
thereby force the user to input something. Also the Cancel button

returns
a False.
Thanks for your help. Otto





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 201
Default InputBox Function & Cancel

Thanks Norman. I'll check it out in the morning. Thanks for your help.
Otto
"Norman Jones" wrote in message
...
Hi Otto,

You can use the StrPtr function:

Sub Tester()
Dim strInput As String

strInput = InputBox("Complete this quotation", _
"InputBox Demo", _
"Friends, Romans and Countrymen")
If StrPtr(strInput) = 0 Then
MsgBox "You pressed Cancel"
Else
If Len(strInput) = 0 Then
MsgBox "OK was pressed but no entry was made."
Else
MsgBox "Your entry was: " & strInput
End If
End If
End Sub

For information about StrPtr see Karl Peterson's site:

http://www.mvps.org/vb/index2.html?tips/varptr.htm


---
Regards,
Norman



"Otto Moehrbach" wrote in message
...
Excel 2002, WinXP
I am using the InputBox Function to get some info from the user.
I want to trap the instance of the user clicking the Cancel button.
Clicking on the Cancel button returns a zero-length string.
No input and clicking on the OK button also returns a zero-length string.
Is there a way to differentiate between the two actions?

I realize that I can use the InputBox Method and specify a type and
thereby force the user to input something. Also the Cancel button
returns a False.
Thanks for your help. Otto





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,327
Default InputBox Function & Cancel

Hi Otto

Application.Inputbox will require certain input types and return False on
cancel. If your last chapter is, as I understand it, saying "I know that and
it's still no good" then no, no distinction between them, you may have to
build a userform and code this yourself. Which is nothing but great fun to
do.

HTH. Best wishes Harald

"Otto Moehrbach" skrev i melding
...
Excel 2002, WinXP
I am using the InputBox Function to get some info from the user.
I want to trap the instance of the user clicking the Cancel button.
Clicking on the Cancel button returns a zero-length string.
No input and clicking on the OK button also returns a zero-length string.
Is there a way to differentiate between the two actions?

I realize that I can use the InputBox Method and specify a type and

thereby
force the user to input something. Also the Cancel button returns a

False.
Thanks for your help. Otto






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
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
Inputbox and cancel button Uddinj1 Excel Programming 5 March 2nd 04 11:27 AM
Cancel button in Inputbox method MiRa Excel Programming 2 November 14th 03 01:04 PM
Inputbox method using type:=8 - How to Cancel? Harlan Grove[_5_] Excel Programming 1 July 9th 03 12:06 AM


All times are GMT +1. The time now is 04:40 AM.

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"