Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default Inputbox Cancellation

Tried several suggestions, but nothing seems to give me
the result I want. Basically I have a group of fields I
want to fill with the result of data gathered from an
Inputbox. Sometimes the response will exist, other times
users may cancel. I am currently unable to determine when
the cancel button has been pressed from the Inputbox
dialog. I can determine that the value assigned to the
inputbox is blank, but that's an okay condition if the
user doesn't want to change the data already in the cell,
so I need to be able to determine what's a conscious
omission versus the press of a cancel button. Any ideas?

Many thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 95
Default Inputbox Cancellation

Michelle,

Try something like the following:

Dim S As String
S = InputBox("Enter something")
If S = "" Then
If StrPtr(S) = 0 Then
MsgBox "User clicked cancel"
Else
MsgBox "User entered empty string"
End If
Else
MsgBox "User entered: " & S
End If


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Michelle" wrote in message
...
Tried several suggestions, but nothing seems to give me
the result I want. Basically I have a group of fields I
want to fill with the result of data gathered from an
Inputbox. Sometimes the response will exist, other times
users may cancel. I am currently unable to determine when
the cancel button has been pressed from the Inputbox
dialog. I can determine that the value assigned to the
inputbox is blank, but that's an okay condition if the
user doesn't want to change the data already in the cell,
so I need to be able to determine what's a conscious
omission versus the press of a cancel button. Any ideas?

Many thanks



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default Inputbox Cancellation

Brilliant! Worked like a charm. But what DOES StrPtr
really do? I couldn't find it in the help files.

Thanks much!!

-----Original Message-----
Michelle,

Try something like the following:

Dim S As String
S = InputBox("Enter something")
If S = "" Then
If StrPtr(S) = 0 Then
MsgBox "User clicked cancel"
Else
MsgBox "User entered empty string"
End If
Else
MsgBox "User entered: " & S
End If


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Michelle" wrote in

message
...
Tried several suggestions, but nothing seems to give me
the result I want. Basically I have a group of fields I
want to fill with the result of data gathered from an
Inputbox. Sometimes the response will exist, other times
users may cancel. I am currently unable to determine

when
the cancel button has been pressed from the Inputbox
dialog. I can determine that the value assigned to the
inputbox is blank, but that's an okay condition if the
user doesn't want to change the data already in the

cell,
so I need to be able to determine what's a conscious
omission versus the press of a cancel button. Any ideas?

Many thanks



.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 95
Default Inputbox Cancellation

Michelle,

StrPtr is not supported by Microsoft, but it is available along
with its cousins VarPtr and ObjPtr. Basically, it returns the
memory address to which the string variable S points. When the
string contents are entirely unallocated, S points to 0. When S
contains any string, including a 0 length empty string, StrPtr
returns a positive memory address location.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Michelle" wrote in message
...
Brilliant! Worked like a charm. But what DOES StrPtr
really do? I couldn't find it in the help files.

Thanks much!!

-----Original Message-----
Michelle,

Try something like the following:

Dim S As String
S = InputBox("Enter something")
If S = "" Then
If StrPtr(S) = 0 Then
MsgBox "User clicked cancel"
Else
MsgBox "User entered empty string"
End If
Else
MsgBox "User entered: " & S
End If


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Michelle" wrote in

message
...
Tried several suggestions, but nothing seems to give me
the result I want. Basically I have a group of fields I
want to fill with the result of data gathered from an
Inputbox. Sometimes the response will exist, other times
users may cancel. I am currently unable to determine

when
the cancel button has been pressed from the Inputbox
dialog. I can determine that the value assigned to the
inputbox is blank, but that's an okay condition if the
user doesn't want to change the data already in the

cell,
so I need to be able to determine what's a conscious
omission versus the press of a cancel button. Any ideas?

Many thanks



.



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
InputBox with VBA Mark[_8_] Excel Discussion (Misc queries) 0 November 24th 08 12:39 AM
InputBox peyman Excel Discussion (Misc queries) 4 September 28th 07 04:53 PM
InputBox GeorgeJ Excel Discussion (Misc queries) 5 July 12th 07 01:20 AM
how do i put in a parallel line on a cell to show a cancellation Janie Excel Worksheet Functions 1 April 13th 07 01:06 PM
inputbox brownti via OfficeKB.com Excel Discussion (Misc queries) 2 February 9th 07 02:37 PM


All times are GMT +1. The time now is 10:00 AM.

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

About Us

"It's about Microsoft Excel"